Repository navigation
test: mocked coverage for multi-turn tool-call formatting in response_api builders - #49
Open
giladsamuels-cognition wants to merge 1 commit into
Open
giladsamuels-cognition wants to merge 1 commit into
giladsamuels-cognition wants to merge 1 commit into
Conversation
…uilders without API calls Co-Authored-By: Gilad Samuels <gilad.samuels@cognition.ai>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Until now, the multi-turn tool-call formatting in
response_api.py(add_responded_tool_callsand each builder'shandle_tool_call) was only tested by@pytest.mark.pricytests, and CI skips those with-m 'not pricy'. This PR adds non-pricy tests totests/llm/test_response_api.py. They reuse the existingcreate_mock_*helpers, and no production code changes.What the tests check:
OpenAIResponseModel,ClaudeResponseModel,OpenAIChatCompletionModel): call 1 returns a tool call →response_text(...)→add_responded_tool_calls→ call 2. The test then asserts the exactinput=/messages=payload sent tocreateon call 2:outputitems, then{"type": "function_call_output", "call_id", "output"}{"role": "assistant", "content": raw.content}, then{"role": "user", "content": [{"type": "tool_result", "tool_use_id", "content"}, ...]}(two parallel calls, order preserved){"name", "role": "tool", "tool_call_id", "content"}per call (two parallel calls)computer_callbranch producescomputer_call_outputwith aninput_imageoutput.AssertionError(all three builders).computer_callresponse raisesAssertionError.add_responded_tool_callsraises when only some tool calls have a response set.toolmessage whoseresponded_tool_callsis unset raisesValueError.To confirm the tests catch real regressions, I temporarily broke the source in four places and 7 tests failed:
call_idkeytool_use_idvaluetool_call_idvalueall_responses_setassertResult with the source restored:
pytest -m 'not pricy' tests/llm/gives 44 passed, 3 skipped.Link to Devin session: https://app.devin.ai/sessions/b30c9ada7dad48f8921cb253abbf1def
Open in Devin Desktop: https://app.devin.ai/desktop/session/b30c9ada7dad48f8921cb253abbf1def?variant=devin
Requested by: @giladsamuels-cognition
Devin Review