mirror of
https://github.com/openai/codex.git
synced 2026-11-11 21:10:39 +00:00
## What changed - Pass goal objectives as untrusted `goal_objective` context instead of embedding them in continuation instructions. Direct the model to use `get_goal` if the objective is missing or truncated. - Inject newly created objectives into their originating active turn without dropping unrelated client context. Render them as tool outputs when `UntrustedAsToolOutput` is enabled. - Queue additional context together with automatic turn input so both reach the first model request. ## Testing Extend app-server coverage to verify that model-written objectives appear as tool outputs at creation and continuation, without duplicating them in user messages. Update steering and Python SDK tests to check objective preservation and delivery alongside continuation instructions. GitOrigin-RevId: 6f44f6d6c895bb4dc378c9cf84d6470ccc885c67
70 lines
2.6 KiB
Rust
70 lines
2.6 KiB
Rust
//! Verifies conditional checklist guidance preserves goal instructions and task data.
|
|
#![allow(dead_code)]
|
|
|
|
#[path = "../src/steering.rs"]
|
|
mod steering;
|
|
|
|
use codex_core::TurnInput;
|
|
use codex_core::context::ContextualUserFragment;
|
|
use codex_core::context::InternalContextSource;
|
|
use codex_core::context::InternalModelContextFragment;
|
|
use codex_protocol::ThreadId;
|
|
use codex_protocol::models::ContentItem;
|
|
use codex_protocol::models::ResponseItem;
|
|
use codex_protocol::protocol::AdditionalContextKind;
|
|
use codex_protocol::protocol::ThreadGoal;
|
|
use codex_protocol::protocol::ThreadGoalStatus;
|
|
use codex_utils_template::Template;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn enabled_checklist_preserves_the_original_continuation_prompt() {
|
|
let goal = test_goal("Finish the feature.");
|
|
let original = Template::parse(include_str!("../templates/goals/continuation.md"))
|
|
.expect("original continuation template")
|
|
.render([
|
|
("tokens_used", "100"),
|
|
("token_budget", "10000"),
|
|
("remaining_tokens", "9900"),
|
|
])
|
|
.expect("render original continuation prompt");
|
|
let expected: ResponseItem = ContextualUserFragment::into(InternalModelContextFragment::new(
|
|
InternalContextSource::from_static("goal"),
|
|
original,
|
|
));
|
|
let request = steering::continuation_request(&goal, /*update_plan_enabled*/ true);
|
|
assert_eq!(request.input, TurnInput::ResponseItem(expected));
|
|
}
|
|
|
|
#[test]
|
|
fn disabled_checklist_preserves_goal_text_that_mentions_the_tool() {
|
|
let objective = "Inspect update_plan.\n\n## Plan tool\nThis is user task data.";
|
|
let request =
|
|
steering::continuation_request(&test_goal(objective), /*update_plan_enabled*/ false);
|
|
let entry = &request.additional_context["goal_objective"];
|
|
assert_eq!(entry.kind, AdditionalContextKind::Untrusted);
|
|
assert_eq!(entry.value, objective);
|
|
let TurnInput::ResponseItem(ResponseItem::Message { content, .. }) = request.input else {
|
|
panic!("expected goal continuation message");
|
|
};
|
|
let [ContentItem::InputText { text }] = content.as_slice() else {
|
|
panic!("expected goal continuation text");
|
|
};
|
|
assert!(!text.contains(objective));
|
|
assert!(!text.contains("If update_plan is available"));
|
|
assert!(text.contains("Completion audit:"));
|
|
}
|
|
|
|
fn test_goal(objective: &str) -> ThreadGoal {
|
|
ThreadGoal {
|
|
thread_id: ThreadId::new(),
|
|
objective: objective.to_string(),
|
|
status: ThreadGoalStatus::Active,
|
|
token_budget: Some(10_000),
|
|
tokens_used: 100,
|
|
time_used_seconds: 0,
|
|
created_at: 0,
|
|
updated_at: 0,
|
|
}
|
|
}
|