mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:22:05 +00:00
Add turn-scoped settings updates to the app server (#40656)
## What changed - Add the experimental `turn/settings/update` method for changing `model`, `effort`, `summary`, and `serviceTier` on a specific live turn without changing future turns. - Report whether the update was applied or the target turn was unavailable, and reject unsupported fields, disabled feature use, unsafe model changes, and direct updates to parent-owned subagents. - Document the method's feature requirements, null handling, and limits. ## Testing - Cover current-turn and future-turn isolation, rejected and unavailable targets, feature and capability gates, saved threads, and subagent ownership. GitOrigin-RevId: 18440f6d7ee5fcd06ae23bd41b22c492b62bb2b5
This commit is contained in:
1 parent
a10c8127f7
commit
9695e71519
13 files changed
+626
-10
No files matched your search
@@ -8,6 +8,8 @@ use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::FunctionCallOutputContentItem;
|
||||
use codex_protocol::protocol::AdditionalContextEntry as CoreAdditionalContextEntry;
|
||||
use codex_protocol::protocol::AdditionalContextKind as CoreAdditionalContextKind;
|
||||
use codex_protocol::protocol::TurnSettingsUpdate;
|
||||
use codex_protocol::protocol::TurnSettingsUpdateOutcome;
|
||||
use codex_skills::system_cache_root_dir;
|
||||
|
||||
use crate::image_url::REMOTE_IMAGE_URL_ERROR;
|
||||
@@ -197,6 +199,45 @@ impl TurnRequestProcessor {
|
||||
.map(|response| Some(response.into()))
|
||||
}
|
||||
|
||||
pub(crate) async fn turn_settings_update(
|
||||
&self,
|
||||
request_id: &ConnectionRequestId,
|
||||
params: TurnSettingsUpdateParams,
|
||||
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
|
||||
let (_, thread) = self.load_thread(¶ms.thread_id).await?;
|
||||
self.ensure_direct_input_allowed(request_id, thread.as_ref())
|
||||
.await?;
|
||||
let (reply, outcome) = oneshot::channel();
|
||||
self.submit_core_op(
|
||||
request_id,
|
||||
&thread,
|
||||
Op::TurnSettings {
|
||||
turn_id: params.turn_id,
|
||||
update: TurnSettingsUpdate {
|
||||
model: params.model,
|
||||
// Match thread/settings/update: public null does not clear effort.
|
||||
effort: params.effort.map(Some),
|
||||
summary: params.summary,
|
||||
service_tier: params.service_tier,
|
||||
},
|
||||
reply,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.map_err(|err| internal_error(format!("failed to submit turn settings: {err}")))?;
|
||||
let outcome = outcome
|
||||
.await
|
||||
.map_err(|_| internal_error("turn settings operation ended before replying"))?;
|
||||
let status = match outcome {
|
||||
TurnSettingsUpdateOutcome::Applied => TurnSettingsUpdateStatus::Applied,
|
||||
TurnSettingsUpdateOutcome::TargetUnavailable => {
|
||||
TurnSettingsUpdateStatus::TargetUnavailable
|
||||
}
|
||||
TurnSettingsUpdateOutcome::Rejected { reason } => return Err(invalid_request(reason)),
|
||||
};
|
||||
Ok(Some(TurnSettingsUpdateResponse { status }.into()))
|
||||
}
|
||||
|
||||
pub(crate) async fn turn_steer(
|
||||
&self,
|
||||
request_id: &ConnectionRequestId,
|
||||
|
||||
Reference in new issue
Block a user