From 84442fd28e146accddfc3a893efef2f4a76c82e8 Mon Sep 17 00:00:00 2001 From: Ajay Krishnan Date: Sun, 19 Jul 2026 01:39:41 -0700 Subject: [PATCH] Test structured async prompt serialization --- test/opencode/smoke_test.rb | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/test/opencode/smoke_test.rb b/test/opencode/smoke_test.rb index b911962..7e160a6 100644 --- a/test/opencode/smoke_test.rb +++ b/test/opencode/smoke_test.rb @@ -126,6 +126,57 @@ class SmokeTest < Minitest::Test assert_equal({}, response) end + def test_send_message_async_serializes_a_structured_child_prompt + schema = { + type: "object", + properties: { + requirement_suggestions: { + type: "array", + items: { type: "string" } + } + }, + required: [ "requirement_suggestions" ], + additionalProperties: false + } + invocation_query = + "Complete the bounded structured request from the preloaded worker skill and immutable Rails context." + expected_body = { + messageID: "msg_worker_1", + parts: [ { type: "text", text: invocation_query } ], + agent: "destination-list-curator", + format: { + type: "json_schema", + schema: schema, + retryCount: 0 + }, + system: "Immutable Rails context" + } + serialized_body = nil + + prompt = stub_request(:post, "#{BASE}/session/#{SESSION_ID}/prompt_async") + .with(body: expected_body.to_json) + .to_return do |request| + serialized_body = request.body + { status: 204, body: "" } + end + + @client.send_message_async( + SESSION_ID, + invocation_query, + agent: "destination-list-curator", + system: "Immutable Rails context", + message_id: "msg_worker_1", + format: { + type: "json_schema", + schema: schema, + retryCount: 0 + } + ) + + assert_equal expected_body.to_json, serialized_body + assert_requested prompt, times: 1 + end + def test_stream_returns_typed_Reply_Result_with_full_text stub_request(:post, "#{BASE}/session/#{SESSION_ID}/prompt_async") .to_return(status: 204, body: "")