Implement environment-bound exec plumbing

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
starr-openai
2026-03-20 18:52:02 -07:00
co-authored by Codex
parent fc135afd78
commit 2de2b1bfbd
77 changed files with 1775 additions and 53 deletions
@@ -201,6 +201,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for this command.",
"type": [
"string",
"null"
]
},
"outputBytesCap": {
"description": "Optional per-stream stdout/stderr capture cap in bytes.\n\nWhen omitted, the server default applies. Cannot be combined with `disableOutputCap`.",
"format": "uint",
@@ -2492,6 +2499,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for the forked thread.",
"type": [
"string",
"null"
]
},
"ephemeral": {
"type": "boolean"
},
@@ -2789,6 +2803,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for the resumed thread.",
"type": [
"string",
"null"
]
},
"model": {
"description": "Configuration overrides for the resumed thread, if any.",
"type": [
@@ -2967,6 +2988,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for this thread.",
"type": [
"string",
"null"
]
},
"ephemeral": {
"type": [
"boolean",
@@ -5924,6 +5924,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for this command.",
"type": [
"string",
"null"
]
},
"outputBytesCap": {
"description": "Optional per-stream stdout/stderr capture cap in bytes.\n\nWhen omitted, the server default applies. Cannot be combined with `disableOutputCap`.",
"format": "uint",
@@ -11822,6 +11829,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for the forked thread.",
"type": [
"string",
"null"
]
},
"ephemeral": {
"type": "boolean"
},
@@ -11892,6 +11906,9 @@
"cwd": {
"type": "string"
},
"environmentId": {
"type": "string"
},
"model": {
"type": "string"
},
@@ -11929,6 +11946,7 @@
"approvalPolicy",
"approvalsReviewer",
"cwd",
"environmentId",
"model",
"modelProvider",
"sandbox",
@@ -13016,6 +13034,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for the resumed thread.",
"type": [
"string",
"null"
]
},
"model": {
"description": "Configuration overrides for the resumed thread, if any.",
"type": [
@@ -13093,6 +13118,9 @@
"cwd": {
"type": "string"
},
"environmentId": {
"type": "string"
},
"model": {
"type": "string"
},
@@ -13130,6 +13158,7 @@
"approvalPolicy",
"approvalsReviewer",
"cwd",
"environmentId",
"model",
"modelProvider",
"sandbox",
@@ -13292,6 +13321,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for this thread.",
"type": [
"string",
"null"
]
},
"ephemeral": {
"type": [
"boolean",
@@ -13374,6 +13410,9 @@
"cwd": {
"type": "string"
},
"environmentId": {
"type": "string"
},
"model": {
"type": "string"
},
@@ -13411,6 +13450,7 @@
"approvalPolicy",
"approvalsReviewer",
"cwd",
"environmentId",
"model",
"modelProvider",
"sandbox",
@@ -2557,6 +2557,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for this command.",
"type": [
"string",
"null"
]
},
"outputBytesCap": {
"description": "Optional per-stream stdout/stderr capture cap in bytes.\n\nWhen omitted, the server default applies. Cannot be combined with `disableOutputCap`.",
"format": "uint",
@@ -9582,6 +9589,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for the forked thread.",
"type": [
"string",
"null"
]
},
"ephemeral": {
"type": "boolean"
},
@@ -9652,6 +9666,9 @@
"cwd": {
"type": "string"
},
"environmentId": {
"type": "string"
},
"model": {
"type": "string"
},
@@ -9689,6 +9706,7 @@
"approvalPolicy",
"approvalsReviewer",
"cwd",
"environmentId",
"model",
"modelProvider",
"sandbox",
@@ -10776,6 +10794,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for the resumed thread.",
"type": [
"string",
"null"
]
},
"model": {
"description": "Configuration overrides for the resumed thread, if any.",
"type": [
@@ -10853,6 +10878,9 @@
"cwd": {
"type": "string"
},
"environmentId": {
"type": "string"
},
"model": {
"type": "string"
},
@@ -10890,6 +10918,7 @@
"approvalPolicy",
"approvalsReviewer",
"cwd",
"environmentId",
"model",
"modelProvider",
"sandbox",
@@ -11052,6 +11081,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for this thread.",
"type": [
"string",
"null"
]
},
"ephemeral": {
"type": [
"boolean",
@@ -11134,6 +11170,9 @@
"cwd": {
"type": "string"
},
"environmentId": {
"type": "string"
},
"model": {
"type": "string"
},
@@ -11171,6 +11210,7 @@
"approvalPolicy",
"approvalsReviewer",
"cwd",
"environmentId",
"model",
"modelProvider",
"sandbox",
@@ -238,6 +238,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for this command.",
"type": [
"string",
"null"
]
},
"outputBytesCap": {
"description": "Optional per-stream stdout/stderr capture cap in bytes.\n\nWhen omitted, the server default applies. Cannot be combined with `disableOutputCap`.",
"format": "uint",
@@ -123,6 +123,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for the forked thread.",
"type": [
"string",
"null"
]
},
"ephemeral": {
"type": "boolean"
},
@@ -2106,6 +2106,9 @@
"cwd": {
"type": "string"
},
"environmentId": {
"type": "string"
},
"model": {
"type": "string"
},
@@ -2143,6 +2146,7 @@
"approvalPolicy",
"approvalsReviewer",
"cwd",
"environmentId",
"model",
"modelProvider",
"sandbox",
@@ -1029,6 +1029,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for the resumed thread.",
"type": [
"string",
"null"
]
},
"model": {
"description": "Configuration overrides for the resumed thread, if any.",
"type": [
@@ -2106,6 +2106,9 @@
"cwd": {
"type": "string"
},
"environmentId": {
"type": "string"
},
"model": {
"type": "string"
},
@@ -2143,6 +2146,7 @@
"approvalPolicy",
"approvalsReviewer",
"cwd",
"environmentId",
"model",
"modelProvider",
"sandbox",
@@ -150,6 +150,13 @@
"null"
]
},
"environmentId": {
"description": "Optional executor environment binding for this thread.",
"type": [
"string",
"null"
]
},
"ephemeral": {
"type": [
"boolean",
@@ -2106,6 +2106,9 @@
"cwd": {
"type": "string"
},
"environmentId": {
"type": "string"
},
"model": {
"type": "string"
},
@@ -2143,6 +2146,7 @@
"approvalPolicy",
"approvalsReviewer",
"cwd",
"environmentId",
"model",
"modelProvider",
"sandbox",
@@ -12,11 +12,15 @@ import type { SandboxPolicy } from "./SandboxPolicy";
* sent only after all `command/exec/outputDelta` notifications for that
* connection have been emitted.
*/
export type CommandExecParams = {
export type CommandExecParams = {
/**
* Command argv vector. Empty arrays are rejected.
*/
command: Array<string>,
command: Array<string>,
/**
* Optional executor environment binding for this command.
*/
environmentId?: string | null,
/**
* Optional client-supplied, connection-scoped process id.
*
@@ -25,56 +29,56 @@ command: Array<string>,
* `command/exec/terminate` calls. When omitted, buffered execution gets an
* internal id that is not exposed to the client.
*/
processId?: string | null,
processId?: string | null,
/**
* Enable PTY mode.
*
* This implies `streamStdin` and `streamStdoutStderr`.
*/
tty?: boolean,
tty?: boolean,
/**
* Allow follow-up `command/exec/write` requests to write stdin bytes.
*
* Requires a client-supplied `processId`.
*/
streamStdin?: boolean,
streamStdin?: boolean,
/**
* Stream stdout/stderr via `command/exec/outputDelta` notifications.
*
* Streamed bytes are not duplicated into the final response and require a
* client-supplied `processId`.
*/
streamStdoutStderr?: boolean,
streamStdoutStderr?: boolean,
/**
* Optional per-stream stdout/stderr capture cap in bytes.
*
* When omitted, the server default applies. Cannot be combined with
* `disableOutputCap`.
*/
outputBytesCap?: number | null,
outputBytesCap?: number | null,
/**
* Disable stdout/stderr capture truncation for this request.
*
* Cannot be combined with `outputBytesCap`.
*/
disableOutputCap?: boolean,
disableOutputCap?: boolean,
/**
* Disable the timeout entirely for this request.
*
* Cannot be combined with `timeoutMs`.
*/
disableTimeout?: boolean,
disableTimeout?: boolean,
/**
* Optional timeout in milliseconds.
*
* When omitted, the server default applies. Cannot be combined with
* `disableTimeout`.
*/
timeoutMs?: number | null,
timeoutMs?: number | null,
/**
* Optional working directory. Defaults to the server cwd.
*/
cwd?: string | null,
cwd?: string | null,
/**
* Optional environment overrides merged into the server-computed
* environment.
@@ -82,12 +86,12 @@ cwd?: string | null,
* Matching names override inherited values. Set a key to `null` to unset
* an inherited variable.
*/
env?: { [key in string]?: string | null } | null,
env?: { [key in string]?: string | null } | null,
/**
* Optional initial PTY size in character cells. Only valid when `tty` is
* true.
*/
size?: CommandExecTerminalSize | null,
size?: CommandExecTerminalSize | null,
/**
* Optional sandbox policy for this command.
*
@@ -17,6 +17,9 @@ import type { SandboxMode } from "./SandboxMode";
* Prefer using thread_id whenever possible.
*/
export type ThreadForkParams = {threadId: string, /**
* Optional executor environment binding for the forked thread.
*/
environmentId?: string | null, /**
* [UNSTABLE] Specify the rollout path to fork from.
* If specified, the thread_id param will be ignored.
*/
@@ -8,7 +8,7 @@ import type { AskForApproval } from "./AskForApproval";
import type { SandboxPolicy } from "./SandboxPolicy";
import type { Thread } from "./Thread";
export type ThreadForkResponse = { thread: Thread, model: string, modelProvider: string, serviceTier: ServiceTier | null, cwd: string, approvalPolicy: AskForApproval,
export type ThreadForkResponse = { thread: Thread, environmentId: string, model: string, modelProvider: string, serviceTier: ServiceTier | null, cwd: string, approvalPolicy: AskForApproval,
/**
* Reviewer currently used for approval requests on this thread.
*/
@@ -21,6 +21,9 @@ import type { SandboxMode } from "./SandboxMode";
* Prefer using thread_id whenever possible.
*/
export type ThreadResumeParams = {threadId: string, /**
* Optional executor environment binding for the resumed thread.
*/
environmentId?: string | null, /**
* [UNSTABLE] FOR CODEX CLOUD - DO NOT USE.
* If specified, the thread will be resumed with the provided history
* instead of loaded from disk.
@@ -8,7 +8,7 @@ import type { AskForApproval } from "./AskForApproval";
import type { SandboxPolicy } from "./SandboxPolicy";
import type { Thread } from "./Thread";
export type ThreadResumeResponse = { thread: Thread, model: string, modelProvider: string, serviceTier: ServiceTier | null, cwd: string, approvalPolicy: AskForApproval,
export type ThreadResumeResponse = { thread: Thread, environmentId: string, model: string, modelProvider: string, serviceTier: ServiceTier | null, cwd: string, approvalPolicy: AskForApproval,
/**
* Reviewer currently used for approval requests on this thread.
*/
@@ -8,7 +8,10 @@ import type { ApprovalsReviewer } from "./ApprovalsReviewer";
import type { AskForApproval } from "./AskForApproval";
import type { SandboxMode } from "./SandboxMode";
export type ThreadStartParams = {model?: string | null, modelProvider?: string | null, serviceTier?: ServiceTier | null | null, cwd?: string | null, approvalPolicy?: AskForApproval | null, /**
export type ThreadStartParams = {model?: string | null, modelProvider?: string | null, /**
* Optional executor environment binding for this thread.
*/
environmentId?: string | null, serviceTier?: ServiceTier | null | null, cwd?: string | null, approvalPolicy?: AskForApproval | null, /**
* Override where approval requests are routed for review on this thread
* and subsequent turns.
*/
@@ -8,7 +8,7 @@ import type { AskForApproval } from "./AskForApproval";
import type { SandboxPolicy } from "./SandboxPolicy";
import type { Thread } from "./Thread";
export type ThreadStartResponse = { thread: Thread, model: string, modelProvider: string, serviceTier: ServiceTier | null, cwd: string, approvalPolicy: AskForApproval,
export type ThreadStartResponse = { thread: Thread, environmentId: string, model: string, modelProvider: string, serviceTier: ServiceTier | null, cwd: string, approvalPolicy: AskForApproval,
/**
* Reviewer currently used for approval requests on this thread.
*/
@@ -3,6 +3,7 @@ use crate::protocol::v2;
impl From<v1::ExecOneOffCommandParams> for v2::CommandExecParams {
fn from(value: v1::ExecOneOffCommandParams) -> Self {
Self {
environment_id: None,
command: value.command,
process_id: None,
tty: false,
@@ -2292,6 +2292,9 @@ pub struct CommandExecTerminalSize {
pub struct CommandExecParams {
/// Command argv vector. Empty arrays are rejected.
pub command: Vec<String>,
/// Optional executor environment binding for this command.
#[ts(optional = nullable)]
pub environment_id: Option<String>,
/// Optional client-supplied, connection-scoped process id.
///
/// Required for `tty`, `streamStdin`, `streamStdoutStderr`, and follow-up
@@ -2459,6 +2462,9 @@ pub struct ThreadStartParams {
pub model: Option<String>,
#[ts(optional = nullable)]
pub model_provider: Option<String>,
/// Optional executor environment binding for this thread.
#[ts(optional = nullable)]
pub environment_id: Option<String>,
#[serde(
default,
deserialize_with = "super::serde_helpers::deserialize_double_option",
@@ -2532,6 +2538,7 @@ pub struct MockExperimentalMethodResponse {
#[ts(export_to = "v2/")]
pub struct ThreadStartResponse {
pub thread: Thread,
pub environment_id: String,
pub model: String,
pub model_provider: String,
pub service_tier: Option<ServiceTier>,
@@ -2560,6 +2567,9 @@ pub struct ThreadStartResponse {
/// Prefer using thread_id whenever possible.
pub struct ThreadResumeParams {
pub thread_id: String,
/// Optional executor environment binding for the resumed thread.
#[ts(optional = nullable)]
pub environment_id: Option<String>,
/// [UNSTABLE] FOR CODEX CLOUD - DO NOT USE.
/// If specified, the thread will be resumed with the provided history
@@ -2618,6 +2628,7 @@ pub struct ThreadResumeParams {
#[ts(export_to = "v2/")]
pub struct ThreadResumeResponse {
pub thread: Thread,
pub environment_id: String,
pub model: String,
pub model_provider: String,
pub service_tier: Option<ServiceTier>,
@@ -2644,6 +2655,9 @@ pub struct ThreadResumeResponse {
/// Prefer using thread_id whenever possible.
pub struct ThreadForkParams {
pub thread_id: String,
/// Optional executor environment binding for the forked thread.
#[ts(optional = nullable)]
pub environment_id: Option<String>,
/// [UNSTABLE] Specify the rollout path to fork from.
/// If specified, the thread_id param will be ignored.
@@ -2695,6 +2709,7 @@ pub struct ThreadForkParams {
#[ts(export_to = "v2/")]
pub struct ThreadForkResponse {
pub thread: Thread,
pub environment_id: String,
pub model: String,
pub model_provider: String,
pub service_tier: Option<ServiceTier>,
@@ -5919,6 +5934,27 @@ mod tests {
.expect("path must be absolute")
}
fn thread_fixture() -> Thread {
Thread {
id: "thr_123".to_string(),
preview: "Preview".to_string(),
ephemeral: false,
model_provider: "openai".to_string(),
created_at: 1,
updated_at: 2,
status: ThreadStatus::Idle,
path: Some(absolute_path("tmp/thread").into()),
cwd: absolute_path("tmp").into(),
cli_version: "1.0.0".to_string(),
source: SessionSource::Exec,
agent_nickname: None,
agent_role: None,
git_info: None,
name: Some("Example".to_string()),
turns: Vec::new(),
}
}
fn test_absolute_path() -> AbsolutePathBuf {
absolute_path("readable")
}
@@ -6428,6 +6464,7 @@ mod tests {
params,
CommandExecParams {
command: vec!["ls".to_string(), "-la".to_string()],
environment_id: None,
process_id: None,
tty: false,
stream_stdin: false,
@@ -6448,6 +6485,7 @@ mod tests {
fn command_exec_params_round_trips_disable_timeout() {
let params = CommandExecParams {
command: vec!["sleep".to_string(), "30".to_string()],
environment_id: None,
process_id: Some("sleep-1".to_string()),
tty: false,
stream_stdin: false,
@@ -6467,6 +6505,7 @@ mod tests {
value,
json!({
"command": ["sleep", "30"],
"environmentId": null,
"processId": "sleep-1",
"disableTimeout": true,
"timeoutMs": null,
@@ -6487,6 +6526,7 @@ mod tests {
fn command_exec_params_round_trips_disable_output_cap() {
let params = CommandExecParams {
command: vec!["yes".to_string()],
environment_id: None,
process_id: Some("yes-1".to_string()),
tty: false,
stream_stdin: false,
@@ -6506,6 +6546,7 @@ mod tests {
value,
json!({
"command": ["yes"],
"environmentId": null,
"processId": "yes-1",
"streamStdoutStderr": true,
"outputBytesCap": null,
@@ -6527,6 +6568,7 @@ mod tests {
fn command_exec_params_round_trips_env_overrides_and_unsets() {
let params = CommandExecParams {
command: vec!["printenv".to_string(), "FOO".to_string()],
environment_id: Some("env-1".to_string()),
process_id: Some("env-1".to_string()),
tty: false,
stream_stdin: false,
@@ -6550,6 +6592,7 @@ mod tests {
value,
json!({
"command": ["printenv", "FOO"],
"environmentId": "env-1",
"processId": "env-1",
"outputBytesCap": null,
"timeoutMs": null,
@@ -6615,6 +6658,7 @@ mod tests {
fn command_exec_params_round_trip_with_size() {
let params = CommandExecParams {
command: vec!["top".to_string()],
environment_id: None,
process_id: Some("pty-1".to_string()),
tty: true,
stream_stdin: false,
@@ -6637,6 +6681,7 @@ mod tests {
value,
json!({
"command": ["top"],
"environmentId": null,
"processId": "pty-1",
"tty": true,
"outputBytesCap": null,
@@ -6656,6 +6701,293 @@ mod tests {
assert_eq!(decoded, params);
}
#[test]
fn thread_start_params_round_trips_environment_id() {
let params = ThreadStartParams {
environment_id: Some("env-1".to_string()),
..Default::default()
};
let value = serde_json::to_value(&params).expect("serialize thread/start params");
assert_eq!(
value,
json!({
"model": null,
"modelProvider": null,
"environmentId": "env-1",
"cwd": null,
"approvalPolicy": null,
"approvalsReviewer": null,
"sandbox": null,
"config": null,
"serviceName": null,
"baseInstructions": null,
"developerInstructions": null,
"personality": null,
"ephemeral": null,
"dynamicTools": null,
"mockExperimentalField": null,
"experimentalRawEvents": false,
"persistExtendedHistory": false,
})
);
let decoded =
serde_json::from_value::<ThreadStartParams>(value).expect("deserialize round-trip");
assert_eq!(decoded, params);
}
#[test]
fn thread_resume_params_round_trips_environment_id() {
let params = ThreadResumeParams {
thread_id: "thr_1".to_string(),
environment_id: Some("env-2".to_string()),
..Default::default()
};
let value = serde_json::to_value(&params).expect("serialize thread/resume params");
assert_eq!(
value,
json!({
"threadId": "thr_1",
"environmentId": "env-2",
"history": null,
"path": null,
"model": null,
"modelProvider": null,
"cwd": null,
"approvalPolicy": null,
"approvalsReviewer": null,
"sandbox": null,
"config": null,
"baseInstructions": null,
"developerInstructions": null,
"personality": null,
"persistExtendedHistory": false,
})
);
let decoded =
serde_json::from_value::<ThreadResumeParams>(value).expect("deserialize round-trip");
assert_eq!(decoded, params);
}
#[test]
fn thread_fork_params_round_trips_environment_id() {
let params = ThreadForkParams {
thread_id: "thr_2".to_string(),
environment_id: Some("env-3".to_string()),
..Default::default()
};
let value = serde_json::to_value(&params).expect("serialize thread/fork params");
assert_eq!(
value,
json!({
"threadId": "thr_2",
"environmentId": "env-3",
"path": null,
"model": null,
"modelProvider": null,
"cwd": null,
"approvalPolicy": null,
"approvalsReviewer": null,
"sandbox": null,
"config": null,
"baseInstructions": null,
"developerInstructions": null,
"persistExtendedHistory": false,
})
);
let decoded =
serde_json::from_value::<ThreadForkParams>(value).expect("deserialize round-trip");
assert_eq!(decoded, params);
}
#[test]
fn thread_start_response_round_trips_environment_id() {
let response = ThreadStartResponse {
thread: thread_fixture(),
environment_id: "env-1".to_string(),
model: "gpt-5".to_string(),
model_provider: "openai".to_string(),
service_tier: Some(ServiceTier::Fast),
cwd: absolute_path("tmp").into(),
approval_policy: AskForApproval::Never,
approvals_reviewer: ApprovalsReviewer::User,
sandbox: SandboxPolicy::ReadOnly {
access: ReadOnlyAccess::FullAccess,
network_access: false,
},
reasoning_effort: None,
};
let value = serde_json::to_value(&response).expect("serialize thread/start response");
assert_eq!(
value,
json!({
"thread": {
"id": "thr_123",
"preview": "Preview",
"ephemeral": false,
"modelProvider": "openai",
"createdAt": 1,
"updatedAt": 2,
"status": {"type": "idle"},
"path": absolute_path_string("tmp/thread"),
"cwd": absolute_path_string("tmp"),
"cliVersion": "1.0.0",
"source": "exec",
"agentNickname": null,
"agentRole": null,
"gitInfo": null,
"name": "Example",
"turns": [],
},
"environmentId": "env-1",
"model": "gpt-5",
"modelProvider": "openai",
"serviceTier": "fast",
"cwd": absolute_path_string("tmp"),
"approvalPolicy": "never",
"approvalsReviewer": "user",
"sandbox": {
"type": "readOnly",
"access": {"type": "fullAccess"},
"networkAccess": false,
},
"reasoningEffort": null,
})
);
let decoded =
serde_json::from_value::<ThreadStartResponse>(value).expect("deserialize round-trip");
assert_eq!(decoded, response);
}
#[test]
fn thread_resume_response_round_trips_environment_id() {
let response = ThreadResumeResponse {
thread: thread_fixture(),
environment_id: "env-2".to_string(),
model: "gpt-5".to_string(),
model_provider: "openai".to_string(),
service_tier: Some(ServiceTier::Fast),
cwd: absolute_path("tmp").into(),
approval_policy: AskForApproval::Never,
approvals_reviewer: ApprovalsReviewer::User,
sandbox: SandboxPolicy::ReadOnly {
access: ReadOnlyAccess::FullAccess,
network_access: false,
},
reasoning_effort: Some(ReasoningEffort::Low),
};
let value = serde_json::to_value(&response).expect("serialize thread/resume response");
assert_eq!(
value,
json!({
"thread": {
"id": "thr_123",
"preview": "Preview",
"ephemeral": false,
"modelProvider": "openai",
"createdAt": 1,
"updatedAt": 2,
"status": {"type": "idle"},
"path": absolute_path_string("tmp/thread"),
"cwd": absolute_path_string("tmp"),
"cliVersion": "1.0.0",
"source": "exec",
"agentNickname": null,
"agentRole": null,
"gitInfo": null,
"name": "Example",
"turns": [],
},
"environmentId": "env-2",
"model": "gpt-5",
"modelProvider": "openai",
"serviceTier": "fast",
"cwd": absolute_path_string("tmp"),
"approvalPolicy": "never",
"approvalsReviewer": "user",
"sandbox": {
"type": "readOnly",
"access": {"type": "fullAccess"},
"networkAccess": false,
},
"reasoningEffort": "low",
})
);
let decoded =
serde_json::from_value::<ThreadResumeResponse>(value).expect("deserialize round-trip");
assert_eq!(decoded, response);
}
#[test]
fn thread_fork_response_round_trips_environment_id() {
let response = ThreadForkResponse {
thread: thread_fixture(),
environment_id: "env-3".to_string(),
model: "gpt-5".to_string(),
model_provider: "openai".to_string(),
service_tier: Some(ServiceTier::Fast),
cwd: absolute_path("tmp").into(),
approval_policy: AskForApproval::Never,
approvals_reviewer: ApprovalsReviewer::User,
sandbox: SandboxPolicy::ReadOnly {
access: ReadOnlyAccess::FullAccess,
network_access: false,
},
reasoning_effort: Some(ReasoningEffort::Medium),
};
let value = serde_json::to_value(&response).expect("serialize thread/fork response");
assert_eq!(
value,
json!({
"thread": {
"id": "thr_123",
"preview": "Preview",
"ephemeral": false,
"modelProvider": "openai",
"createdAt": 1,
"updatedAt": 2,
"status": {"type": "idle"},
"path": absolute_path_string("tmp/thread"),
"cwd": absolute_path_string("tmp"),
"cliVersion": "1.0.0",
"source": "exec",
"agentNickname": null,
"agentRole": null,
"gitInfo": null,
"name": "Example",
"turns": [],
},
"environmentId": "env-3",
"model": "gpt-5",
"modelProvider": "openai",
"serviceTier": "fast",
"cwd": absolute_path_string("tmp"),
"approvalPolicy": "never",
"approvalsReviewer": "user",
"sandbox": {
"type": "readOnly",
"access": {"type": "fullAccess"},
"networkAccess": false,
},
"reasoningEffort": "medium",
})
);
let decoded =
serde_json::from_value::<ThreadForkResponse>(value).expect("deserialize round-trip");
assert_eq!(decoded, response);
}
#[test]
fn command_exec_resize_round_trips() {
let params = CommandExecResizeParams {