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
2 changes: 1 addition & 1 deletion codex-rs/core/src/session/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8883,7 +8883,7 @@ async fn completed_goal_accounts_current_turn_tokens_before_tool_response() -> a
assert_eq!(complete_output["remainingTokens"], 0);
assert_eq!(
complete_output["completionBudgetReport"],
"Goal achieved. Report final budget usage to the user: tokens used: 580 of 500."
"Goal achieved. Report final usage from this tool result's structured goal fields. If `goal.tokenBudget` is present, include token usage from `goal.tokensUsed` and `goal.tokenBudget`. If `goal.timeUsedSeconds` is greater than 0, summarize elapsed time in a concise, human-friendly form appropriate to the response language."
);
let requests = responses.requests();
let completion_followup_request = requests
Expand Down
19 changes: 6 additions & 13 deletions codex-rs/core/src/tools/handlers/goal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,13 @@ fn goal_response(
}

fn completion_budget_report(goal: &ThreadGoal) -> Option<String> {
let mut parts = Vec::new();
if let Some(budget) = goal.token_budget {
parts.push(format!("tokens used: {} of {budget}", goal.tokens_used));
}
if goal.time_used_seconds > 0 {
parts.push(format!("time used: {} seconds", goal.time_used_seconds));
}
if parts.is_empty() {
if goal.token_budget.is_none() && goal.time_used_seconds <= 0 {
None
} else {
Some(format!(
"Goal achieved. Report final budget usage to the user: {}.",
parts.join("; ")
))
Some(
"Goal achieved. Report final usage from this tool result's structured goal fields. If `goal.tokenBudget` is present, include token usage from `goal.tokensUsed` and `goal.tokenBudget`. If `goal.timeUsedSeconds` is greater than 0, summarize elapsed time in a concise, human-friendly form appropriate to the response language."
.to_string(),
)
}
}

Expand Down Expand Up @@ -131,7 +124,7 @@ mod tests {
goal: Some(goal),
remaining_tokens: Some(6_750),
completion_budget_report: Some(
"Goal achieved. Report final budget usage to the user: tokens used: 3250 of 10000; time used: 75 seconds."
"Goal achieved. Report final usage from this tool result's structured goal fields. If `goal.tokenBudget` is present, include token usage from `goal.tokensUsed` and `goal.tokenBudget`. If `goal.timeUsedSeconds` is greater than 0, summarize elapsed time in a concise, human-friendly form appropriate to the response language."
.to_string()
),
}
Expand Down
Loading