Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4217,4 +4217,4 @@
}
],
"title": "ClientRequest"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17071,4 +17071,4 @@
},
"title": "CodexAppServerProtocol",
"type": "object"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15326,4 +15326,4 @@
},
"title": "CodexAppServerProtocolV2",
"type": "object"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
],
"title": "WindowsSandboxSetupStartParams",
"type": "object"
}
}
17 changes: 17 additions & 0 deletions codex-rs/app-server-protocol/src/protocol/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,23 @@ client_request_definitions! {
params: v2::ThreadUnsubscribeParams,
response: v2::ThreadUnsubscribeResponse,
},
#[experimental("thread/increment_elicitation")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a docstring here describe what these two endpoints do?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

& maybe make it clear that this only applies to unified exec as a workaround?

/// Increment the thread-local out-of-band elicitation counter.
///
/// This is used by external helpers to pause timeout accounting while a user
/// approval or other elicitation is pending outside the app-server request flow.
ThreadIncrementElicitation => "thread/increment_elicitation" {
params: v2::ThreadIncrementElicitationParams,
response: v2::ThreadIncrementElicitationResponse,
},
#[experimental("thread/decrement_elicitation")]
/// Decrement the thread-local out-of-band elicitation counter.
///
/// When the count reaches zero, timeout accounting resumes for the thread.
ThreadDecrementElicitation => "thread/decrement_elicitation" {
params: v2::ThreadDecrementElicitationParams,
response: v2::ThreadDecrementElicitationResponse,
},
ThreadSetName => "thread/name/set" {
params: v2::ThreadSetNameParams,
response: v2::ThreadSetNameResponse,
Expand Down
40 changes: 40 additions & 0 deletions codex-rs/app-server-protocol/src/protocol/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,46 @@ pub enum ThreadUnsubscribeStatus {
Unsubscribed,
}

/// Parameters for `thread/increment_elicitation`.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadIncrementElicitationParams {
/// Thread whose out-of-band elicitation counter should be incremented.
pub thread_id: String,
}

/// Response for `thread/increment_elicitation`.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadIncrementElicitationResponse {
/// Current out-of-band elicitation count after the increment.
pub count: u64,
/// Whether timeout accounting is paused after applying the increment.
pub paused: bool,
}

/// Parameters for `thread/decrement_elicitation`.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadDecrementElicitationParams {
/// Thread whose out-of-band elicitation counter should be decremented.
pub thread_id: String,
}

/// Response for `thread/decrement_elicitation`.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadDecrementElicitationResponse {
/// Current out-of-band elicitation count after the decrement.
pub count: u64,
/// Whether timeout accounting remains paused after applying the decrement.
pub paused: bool,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
Expand Down
46 changes: 46 additions & 0 deletions codex-rs/app-server-test-client/scripts/live_elicitation_hold.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh
set -eu

require_env() {
eval "value=\${$1-}"
if [ -z "$value" ]; then
echo "missing required env var: $1" >&2
exit 1
fi
}

require_env APP_SERVER_URL
require_env APP_SERVER_TEST_CLIENT_BIN

thread_id="${CODEX_THREAD_ID:-${THREAD_ID-}}"
if [ -z "$thread_id" ]; then
echo "missing required env var: CODEX_THREAD_ID" >&2
exit 1
fi

hold_seconds="${ELICITATION_HOLD_SECONDS:-15}"
incremented=0

cleanup() {
if [ "$incremented" -eq 1 ]; then
"$APP_SERVER_TEST_CLIENT_BIN" --url "$APP_SERVER_URL" \
thread-decrement-elicitation "$thread_id" >/dev/null 2>&1 || true
fi
}

trap cleanup EXIT INT TERM HUP

echo "[elicitation-hold] increment thread=$thread_id"
"$APP_SERVER_TEST_CLIENT_BIN" --url "$APP_SERVER_URL" \
thread-increment-elicitation "$thread_id"
incremented=1

echo "[elicitation-hold] sleeping ${hold_seconds}s"
sleep "$hold_seconds"

echo "[elicitation-hold] decrement thread=$thread_id"
"$APP_SERVER_TEST_CLIENT_BIN" --url "$APP_SERVER_URL" \
thread-decrement-elicitation "$thread_id"
incremented=0

echo "[elicitation-hold] done"
Loading
Loading