Skip to content
Open
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
12 changes: 11 additions & 1 deletion codex-rs/core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ impl ModelClient {
let max_attempts = self.provider.request_max_retries();
for attempt in 0..=max_attempts {
match self
.attempt_stream_responses(attempt, &payload_json, &auth_manager)
.attempt_stream_responses(
attempt,
&payload_json,
&auth_manager,
prompt.is_review_turn,
)
.await
{
Ok(stream) => {
Expand Down Expand Up @@ -272,6 +277,7 @@ impl ModelClient {
attempt: u64,
payload_json: &Value,
auth_manager: &Option<Arc<AuthManager>>,
is_review_turn: bool,
) -> std::result::Result<ResponseStream, StreamAttemptError> {
// Always fetch the latest auth in case a prior attempt refreshed the token.
let auth = auth_manager.as_ref().and_then(|m| m.auth());
Expand All @@ -293,6 +299,10 @@ impl ModelClient {
// Send session_id for compatibility.
.header("conversation_id", self.conversation_id.to_string())
.header("session_id", self.conversation_id.to_string())
.header(
"action_kind",
if is_review_turn { "review" } else { "turn" },
)
.header(reqwest::header::ACCEPT, "text/event-stream")
.json(payload_json);

Expand Down
3 changes: 3 additions & 0 deletions codex-rs/core/src/client_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ pub struct Prompt {

/// Optional the output schema for the model's response.
pub output_schema: Option<Value>,

/// Marks whether this prompt is part of a review turn.
pub is_review_turn: bool,
}

impl Prompt {
Expand Down
1 change: 1 addition & 0 deletions codex-rs/core/src/codex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,7 @@ async fn run_turn(
parallel_tool_calls,
base_instructions_override: turn_context.base_instructions.clone(),
output_schema: turn_context.final_output_json_schema.clone(),
is_review_turn: turn_context.is_review_mode,
};

let mut retries = 0;
Expand Down
2 changes: 2 additions & 0 deletions codex-rs/core/tests/suite/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,14 @@ async fn includes_conversation_id_and_model_headers_in_request() {
let request_conversation_id = request.headers.get("conversation_id").unwrap();
let request_authorization = request.headers.get("authorization").unwrap();
let request_originator = request.headers.get("originator").unwrap();
let turn_kind = request.headers.get("action_kind").unwrap();

assert_eq!(
request_conversation_id.to_str().unwrap(),
conversation_id.to_string()
);
assert_eq!(request_originator.to_str().unwrap(), "codex_cli_rs");
assert_eq!(turn_kind.to_str().unwrap(), "turn");
assert_eq!(
request_authorization.to_str().unwrap(),
"Bearer Test API Key"
Expand Down
Loading