Test text stringify errors in the code mode runtime (#39505)

## What changed

Move circular-value coverage for the `text()` helper from the core integration
suite to the in-process code mode runtime tests. Verify that stringification
returns no content and surfaces the V8 circular-structure error without needing
a mock server or network access.

GitOrigin-RevId: d506591af5ae8ce0a8c7305d633a7b0f2e458335
This commit is contained in:
jif authored and copyberry committed 2026-08-19 15:37:26 +00:00
1 parent 36268f177f
commit b0cdcce616
2 files changed
+41 -40

No files matched your search

-40
View File
@@ -3686,46 +3686,6 @@ text("after");
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn code_mode_surfaces_text_stringify_errors() -> Result<()> {
skip_if_no_network!(Ok(()));
let server = responses::start_mock_server().await;
let (_test, second_mock) = run_code_mode_turn(
&server,
"use exec to return circular text",
r#"
const circular = {};
circular.self = circular;
text(circular);
"#,
)
.await?;
let req = second_mock.single_request();
let items = custom_tool_output_items(&req, "call-1");
let (_, success) = req
.custom_tool_call_output_content_and_success("call-1")
.expect("custom tool output should be present");
assert_ne!(
success,
Some(true),
"circular stringify unexpectedly succeeded"
);
assert_eq!(items.len(), 2);
assert_regex_match(
concat!(
r"(?s)\A",
r"Script failed\nWall time \d+\.\d seconds\nOutput:\n\z"
),
text_item(&items, /*index*/ 0),
);
assert!(text_item(&items, /*index*/ 1).contains("Script error:"));
assert!(text_item(&items, /*index*/ 1).contains("Converting circular structure to JSON"));
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn code_mode_can_output_images_via_global_helper() -> Result<()> {
skip_if_no_network!(Ok(()));