2025-08-15 12:44:40 -07:00
|
|
|
[package]
|
2025-11-24 12:22:18 -08:00
|
|
|
edition.workspace = true
|
|
|
|
|
license.workspace = true
|
2026-02-19 10:38:57 -08:00
|
|
|
name = "codex-protocol"
|
|
|
|
|
version.workspace = true
|
2025-08-15 12:44:40 -07:00
|
|
|
|
|
|
|
|
[lib]
|
|
|
|
|
name = "codex_protocol"
|
|
|
|
|
path = "src/lib.rs"
|
|
|
|
|
|
|
|
|
|
[lints]
|
|
|
|
|
workspace = true
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
2026-01-28 01:43:17 -07:00
|
|
|
codex-execpolicy = { workspace = true }
|
2026-02-19 10:38:57 -08:00
|
|
|
codex-git = { workspace = true }
|
2025-12-12 15:25:22 -08:00
|
|
|
codex-utils-absolute-path = { workspace = true }
|
2025-10-27 16:58:10 +00:00
|
|
|
codex-utils-image = { workspace = true }
|
2025-09-22 18:47:01 +02:00
|
|
|
icu_decimal = { workspace = true }
|
|
|
|
|
icu_locale_core = { workspace = true }
|
2025-10-29 20:46:45 +00:00
|
|
|
icu_provider = { workspace = true, features = ["sync"] }
|
[hooks] use a user message > developer message for prompt continuation (#14867)
## Summary
Persist Stop-hook continuation prompts as `user` messages instead of
hidden `developer` messages + some requested integration tests
This is a followup to @pakrym 's comment in
https://github.com/openai/codex/pull/14532 to make sure stop-block
continuation prompts match training for turn loops
- Stop continuation now writes `<hook_prompt hook_run_id="...">stop
hook's user prompt<hook_prompt>`
- Introduces quick-xml dependency, though we already indirectly depended
on it anyway via syntect
- This PR only has about 500 lines of actual logic changes, the rest is
tests/schema
## Testing
Example run (with a sessionstart hook and 3 stop hooks) - this shows
context added by session start, then two stop hooks sending their own
additional prompts in a new turn. The model responds with a single
message addressing both. Then when that turn ends, the hooks detect that
they just ran using `stop_hook_active` and decide not to infinite loop
test files for this (unzip, move codex -> .codex):
[codex.zip](https://github.com/user-attachments/files/26075806/codex.zip)
```
› cats
• Running SessionStart hook: lighting the observatory
SessionStart hook (completed)
warning: Hi, I'm a session start hook for wizard-tower (startup).
hook context: A wimboltine stonpet is an exotic cuisine from hyperspace
• Cats are tiny zen wizards, my friend: equal parts nap, mystery, and chaos. If you want, we can talk
cat facts, cat breeds, cat names, or build something cat-themed in this repo.
• Running Stop hook: checking the tower wards
• Running Stop hook: sacking the guards
• Running Stop hook: hiring the guards
Stop hook (completed)
warning: Wizard Tower Stop hook reviewed the completed reply (177 chars).
Stop hook (blocked)
warning: Wizard Tower Stop hook continuing conversation
feedback: cook the stonpet
Stop hook (blocked)
warning: Wizard Tower Stop hook continuing conversation
feedback: eat the cooked stonpet
• Stonpet’s cooked, aloha style: flash-seared over a blue quasiflame, glazed with nebula salt, and
rested until the hyperspace juices settle.
Now we eat with gratitude, my friend. One mindful bite in, and the flavor is pure cosmic surf:
smoky, bright, and totally out of this dimension.
• Running Stop hook: checking the tower wards
• Running Stop hook: sacking the guards
• Running Stop hook: hiring the guards
Stop hook (completed)
warning: Wizard Tower Stop hook reviewed the completed reply (285 chars).
Stop hook (completed)
warning: Wizard Tower Stop hook saw a second pass and stayed calm to avoid a loop.
Stop hook (completed)
warning: Wizard Tower Stop hook saw a second pass and stayed calm to avoid a loop.
```
2026-03-19 10:53:08 -07:00
|
|
|
quick-xml = { workspace = true, features = ["serialize"] }
|
fix: add more fields to ThreadStartResponse and ThreadResumeResponse (#6847)
This adds the following fields to `ThreadStartResponse` and
`ThreadResumeResponse`:
```rust
pub model: String,
pub model_provider: String,
pub cwd: PathBuf,
pub approval_policy: AskForApproval,
pub sandbox: SandboxPolicy,
pub reasoning_effort: Option<ReasoningEffort>,
```
This is important because these fields are optional in
`ThreadStartParams` and `ThreadResumeParams`, so the caller needs to be
able to determine what values were ultimately used to start/resume the
conversation. (Though note that any of these could be changed later
between turns in the conversation.)
Though to get this information reliably, it must be read from the
internal `SessionConfiguredEvent` that is created in response to the
start of a conversation. Because `SessionConfiguredEvent` (as defined in
`codex-rs/protocol/src/protocol.rs`) did not have all of these fields, a
number of them had to be added as part of this PR.
Because `SessionConfiguredEvent` is referenced in many tests, test
instances of `SessionConfiguredEvent` had to be updated, as well, which
is why this PR touches so many files.
2025-11-18 21:18:43 -08:00
|
|
|
schemars = { workspace = true }
|
2025-09-22 18:47:01 +02:00
|
|
|
serde = { workspace = true, features = ["derive"] }
|
|
|
|
|
serde_json = { workspace = true }
|
|
|
|
|
serde_with = { workspace = true, features = ["macros", "base64"] }
|
|
|
|
|
strum = { workspace = true }
|
|
|
|
|
strum_macros = { workspace = true }
|
|
|
|
|
sys-locale = { workspace = true }
|
|
|
|
|
tracing = { workspace = true }
|
|
|
|
|
ts-rs = { workspace = true, features = [
|
2025-09-18 07:37:03 -07:00
|
|
|
"uuid-impl",
|
|
|
|
|
"serde-json-impl",
|
|
|
|
|
"no-serde-warnings",
|
|
|
|
|
] }
|
2025-10-20 13:34:44 -07:00
|
|
|
uuid = { workspace = true, features = ["serde", "v7", "v4"] }
|
2025-08-18 09:36:57 -07:00
|
|
|
|
|
|
|
|
[dev-dependencies]
|
2025-09-23 13:31:36 -07:00
|
|
|
anyhow = { workspace = true }
|
fix: add more fields to ThreadStartResponse and ThreadResumeResponse (#6847)
This adds the following fields to `ThreadStartResponse` and
`ThreadResumeResponse`:
```rust
pub model: String,
pub model_provider: String,
pub cwd: PathBuf,
pub approval_policy: AskForApproval,
pub sandbox: SandboxPolicy,
pub reasoning_effort: Option<ReasoningEffort>,
```
This is important because these fields are optional in
`ThreadStartParams` and `ThreadResumeParams`, so the caller needs to be
able to determine what values were ultimately used to start/resume the
conversation. (Though note that any of these could be changed later
between turns in the conversation.)
Though to get this information reliably, it must be read from the
internal `SessionConfiguredEvent` that is created in response to the
start of a conversation. Because `SessionConfiguredEvent` (as defined in
`codex-rs/protocol/src/protocol.rs`) did not have all of these fields, a
number of them had to be added as part of this PR.
Because `SessionConfiguredEvent` is referenced in many tests, test
instances of `SessionConfiguredEvent` had to be updated, as well, which
is why this PR touches so many files.
2025-11-18 21:18:43 -08:00
|
|
|
pretty_assertions = { workspace = true }
|
2025-09-22 18:47:01 +02:00
|
|
|
tempfile = { workspace = true }
|
2025-09-08 18:05:08 -07:00
|
|
|
|
|
|
|
|
[package.metadata.cargo-shear]
|
2025-10-29 20:46:45 +00:00
|
|
|
# Required because:
|
|
|
|
|
# `icu_provider`: contains a required `sync` feature for `icu_decimal`
|
|
|
|
|
# `strum`: as strum_macros in non-nightly builds
|
|
|
|
|
ignored = ["icu_provider", "strum"]
|