mirror of
https://github.com/openai/codex.git
synced 2026-06-01 19:02:59 +00:00
## Why The Docker remote-env coverage was failing before it reached the behavior those tests are meant to exercise. The remote-aware test fixture only registered the remote environment, so tests that intentionally select both `local` and `remote` could not start a turn. After that was fixed, two tests exposed stale fixtures: the approval test was auto-approving under workspace-write, and the remote `view_image` test was writing invalid PNG bytes. ## What Changed - Added `EnvironmentManager::create_for_tests_with_local(...)` so tests can keep the provider default while also selecting `local` explicitly. - Updated `build_remote_aware()` to use that test-only manager when a remote exec-server URL is present. - Changed the remote apply-patch approval helper to use `SandboxPolicy::new_read_only_policy()` so the test actually exercises approval caching per environment. - Replaced the hardcoded remote `view_image` PNG blob with the existing `png_bytes(...)` helper so the test uses a valid image fixture. ## Validation Ran these isolated Docker remote-env tests on the devbox with `$remote-tests` setup: - `suite::remote_env::apply_patch_freeform_routes_to_selected_remote_environment` - `suite::remote_env::apply_patch_approvals_are_remembered_per_environment` - `suite::remote_env::apply_patch_intercepted_exec_command_routes_to_selected_remote_environment` - `suite::remote_env::exec_command_routes_to_selected_remote_environment` - `suite::view_image::view_image_routes_to_selected_remote_environment` All five pass.
96 lines
3.3 KiB
Rust
96 lines
3.3 KiB
Rust
use codex_features::Feature;
|
|
use core_test_support::responses::ev_completed;
|
|
use core_test_support::responses::ev_response_created;
|
|
use core_test_support::responses::mount_sse_once;
|
|
use core_test_support::responses::sse;
|
|
use core_test_support::responses::start_mock_server;
|
|
use core_test_support::test_codex::test_codex;
|
|
|
|
const HIERARCHICAL_AGENTS_SNIPPET: &str =
|
|
"Files called AGENTS.md commonly appear in many places inside a container";
|
|
|
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
|
async fn hierarchical_agents_appends_to_project_doc_in_user_instructions() {
|
|
let server = start_mock_server().await;
|
|
let resp_mock = mount_sse_once(
|
|
&server,
|
|
sse(vec![ev_response_created("resp1"), ev_completed("resp1")]),
|
|
)
|
|
.await;
|
|
|
|
let mut builder = test_codex()
|
|
.with_config(|config| {
|
|
config
|
|
.features
|
|
.enable(Feature::ChildAgentsMd)
|
|
.expect("test config should allow feature update");
|
|
})
|
|
.with_workspace_setup(|cwd, fs| async move {
|
|
let agents_md = cwd.join("AGENTS.md");
|
|
fs.write_file(&agents_md, b"be nice".to_vec(), /*sandbox*/ None)
|
|
.await?;
|
|
Ok::<(), anyhow::Error>(())
|
|
});
|
|
let test = builder
|
|
.build_with_remote_env(&server)
|
|
.await
|
|
.expect("build test codex");
|
|
|
|
test.submit_turn("hello").await.expect("submit turn");
|
|
|
|
let request = resp_mock.single_request();
|
|
let user_messages = request.message_input_texts("user");
|
|
let instructions = user_messages
|
|
.iter()
|
|
.find(|text| text.starts_with("# AGENTS.md instructions for "))
|
|
.expect("instructions message");
|
|
assert!(
|
|
instructions.contains("be nice"),
|
|
"expected AGENTS.md text included: {instructions}"
|
|
);
|
|
let snippet_pos = instructions
|
|
.find(HIERARCHICAL_AGENTS_SNIPPET)
|
|
.expect("expected hierarchical agents snippet");
|
|
let base_pos = instructions
|
|
.find("be nice")
|
|
.expect("expected AGENTS.md text");
|
|
assert!(
|
|
snippet_pos > base_pos,
|
|
"expected hierarchical agents message appended after base instructions: {instructions}"
|
|
);
|
|
}
|
|
|
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
|
async fn hierarchical_agents_emits_when_no_project_doc() {
|
|
let server = start_mock_server().await;
|
|
let resp_mock = mount_sse_once(
|
|
&server,
|
|
sse(vec![ev_response_created("resp1"), ev_completed("resp1")]),
|
|
)
|
|
.await;
|
|
|
|
let mut builder = test_codex().with_config(|config| {
|
|
config
|
|
.features
|
|
.enable(Feature::ChildAgentsMd)
|
|
.expect("test config should allow feature update");
|
|
});
|
|
let test = builder
|
|
.build_with_remote_env(&server)
|
|
.await
|
|
.expect("build test codex");
|
|
|
|
test.submit_turn("hello").await.expect("submit turn");
|
|
|
|
let request = resp_mock.single_request();
|
|
let user_messages = request.message_input_texts("user");
|
|
let instructions = user_messages
|
|
.iter()
|
|
.find(|text| text.starts_with("# AGENTS.md instructions for "))
|
|
.expect("instructions message");
|
|
assert!(
|
|
instructions.contains(HIERARCHICAL_AGENTS_SNIPPET),
|
|
"expected hierarchical agents message appended: {instructions}"
|
|
);
|
|
}
|