mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
handle delegated requests in downstream clients
This commit is contained in:
@@ -1314,6 +1314,30 @@ async fn handle_server_request(
|
||||
)
|
||||
.await
|
||||
}
|
||||
ServerRequest::ModelRequest { request_id, params } => {
|
||||
reject_server_request(
|
||||
client,
|
||||
request_id,
|
||||
&method,
|
||||
format!(
|
||||
"delegated model requests are not supported in exec mode for thread `{}`",
|
||||
params.thread_id
|
||||
),
|
||||
)
|
||||
.await
|
||||
}
|
||||
ServerRequest::ModelCompact { request_id, params } => {
|
||||
reject_server_request(
|
||||
client,
|
||||
request_id,
|
||||
&method,
|
||||
format!(
|
||||
"delegated model compaction is not supported in exec mode for thread `{}`",
|
||||
params.thread_id
|
||||
),
|
||||
)
|
||||
.await
|
||||
}
|
||||
ServerRequest::ApplyPatchApproval { request_id, params } => {
|
||||
reject_server_request(
|
||||
client,
|
||||
|
||||
@@ -398,6 +398,8 @@ fn server_request_thread_id(request: &ServerRequest) -> Option<ThreadId> {
|
||||
ServerRequest::DynamicToolCall { params, .. } => {
|
||||
ThreadId::from_string(¶ms.thread_id).ok()
|
||||
}
|
||||
ServerRequest::ModelRequest { params, .. } => ThreadId::from_string(¶ms.thread_id).ok(),
|
||||
ServerRequest::ModelCompact { params, .. } => ThreadId::from_string(¶ms.thread_id).ok(),
|
||||
ServerRequest::ChatgptAuthTokensRefresh { .. }
|
||||
| ServerRequest::ApplyPatchApproval { .. }
|
||||
| ServerRequest::ExecCommandApproval { .. } => None,
|
||||
|
||||
@@ -90,6 +90,16 @@ impl PendingAppServerRequests {
|
||||
.to_string(),
|
||||
})
|
||||
}
|
||||
ServerRequest::ModelRequest { request_id, .. } => Some(UnsupportedAppServerRequest {
|
||||
request_id: request_id.clone(),
|
||||
message: "Delegated model requests are not available in app-server TUI yet."
|
||||
.to_string(),
|
||||
}),
|
||||
ServerRequest::ModelCompact { request_id, .. } => Some(UnsupportedAppServerRequest {
|
||||
request_id: request_id.clone(),
|
||||
message: "Delegated model compaction is not available in app-server TUI yet."
|
||||
.to_string(),
|
||||
}),
|
||||
ServerRequest::ChatgptAuthTokensRefresh { .. } => None,
|
||||
ServerRequest::ApplyPatchApproval { request_id, .. } => {
|
||||
Some(UnsupportedAppServerRequest {
|
||||
@@ -501,6 +511,76 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_delegated_model_requests_as_unsupported() {
|
||||
let mut pending = PendingAppServerRequests::default();
|
||||
|
||||
let unsupported = pending
|
||||
.note_server_request(&ServerRequest::ModelRequest {
|
||||
request_id: AppServerRequestId::Integer(101),
|
||||
params: codex_app_server_protocol::ModelRequestParams {
|
||||
thread_id: "thread-1".to_string(),
|
||||
turn_id: "turn-1".to_string(),
|
||||
request_id: "request-1".to_string(),
|
||||
request: codex_app_server_protocol::ModelRequestEnvelope {
|
||||
model: "gpt-5".to_string(),
|
||||
instructions: "hi".to_string(),
|
||||
input: Vec::new(),
|
||||
tools: Vec::new(),
|
||||
tool_choice: "auto".to_string(),
|
||||
parallel_tool_calls: false,
|
||||
reasoning: None,
|
||||
store: false,
|
||||
stream: true,
|
||||
include: Vec::new(),
|
||||
service_tier: None,
|
||||
prompt_cache_key: None,
|
||||
text: None,
|
||||
request_headers: None,
|
||||
},
|
||||
},
|
||||
})
|
||||
.expect("delegated model requests should be rejected");
|
||||
|
||||
assert_eq!(unsupported.request_id, AppServerRequestId::Integer(101));
|
||||
assert_eq!(
|
||||
unsupported.message,
|
||||
"Delegated model requests are not available in app-server TUI yet."
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_delegated_model_compaction_as_unsupported() {
|
||||
let mut pending = PendingAppServerRequests::default();
|
||||
|
||||
let unsupported = pending
|
||||
.note_server_request(&ServerRequest::ModelCompact {
|
||||
request_id: AppServerRequestId::Integer(102),
|
||||
params: codex_app_server_protocol::ModelCompactParams {
|
||||
thread_id: "thread-1".to_string(),
|
||||
turn_id: "turn-1".to_string(),
|
||||
request_id: "request-1".to_string(),
|
||||
request: codex_app_server_protocol::ModelCompactEnvelope {
|
||||
model: "gpt-5".to_string(),
|
||||
input: Vec::new(),
|
||||
instructions: "hi".to_string(),
|
||||
tools: Vec::new(),
|
||||
parallel_tool_calls: false,
|
||||
reasoning: None,
|
||||
text: None,
|
||||
request_headers: None,
|
||||
},
|
||||
},
|
||||
})
|
||||
.expect("delegated model compaction should be rejected");
|
||||
|
||||
assert_eq!(unsupported.request_id, AppServerRequestId::Integer(102));
|
||||
assert_eq!(
|
||||
unsupported.message,
|
||||
"Delegated model compaction is not available in app-server TUI yet."
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_mark_chatgpt_auth_refresh_as_unsupported() {
|
||||
let mut pending = PendingAppServerRequests::default();
|
||||
|
||||
@@ -5791,6 +5791,8 @@ impl ChatWidget {
|
||||
self.on_request_user_input(request_user_input_from_params(params));
|
||||
}
|
||||
ServerRequest::DynamicToolCall { .. }
|
||||
| ServerRequest::ModelRequest { .. }
|
||||
| ServerRequest::ModelCompact { .. }
|
||||
| ServerRequest::ChatgptAuthTokensRefresh { .. }
|
||||
| ServerRequest::ApplyPatchApproval { .. }
|
||||
| ServerRequest::ExecCommandApproval { .. } => {
|
||||
|
||||
Reference in New Issue
Block a user