Repository navigation
fix: admit fco_ and other item id prefixes OpenAI accepts - #553
Conversation
Signed-off-by: maral <maralbahari.98@gmail.com>
|
the new |
tjtanaa
left a comment
There was a problem hiding this comment.
One storage compatibility concern with the newly shared call/result prefixes. Based on source inspection; I did not run tests.
| InputItem::ToolSearchCall(_) => Some(&["tsc_"]), | ||
| InputItem::ToolSearchOutput(_) => Some(&["tso_"]), | ||
| InputItem::CustomToolCall(_) => Some(&["ctc_", "ctco_"]), | ||
| InputItem::ShellCall(_) => Some(&["sh_", "sho_"]), |
There was a problem hiding this comment.
Could we preserve the requested item kind when resolving stored references? The new shell and custom-tool aliases make their call and result ID namespaces overlap. Responses and Conversations both resolve stored items by public ID without checking the item kind, so successful admission no longer guarantees that the resolved item is still a call rather than its result. Please check provider behavior for a kind mismatch and add a storage-backed regression that asserts the resolved kind, not just the admission status.
There was a problem hiding this comment.
Thanks, I checked the provider first. OpenAI does not preserve the requested kind either: it resolves a reused public ID to the stored item, whatever type the request names. So the gateway's kind-agnostic resolution is the parity behavior, and I kept it.
Recorded in be1a0ff (OpenAI and gateway):
- Conversations (
conversations-item-id-prefixes-*.yaml, t15-t18): sending afunction_callwith a storedfunction_call_outputID, afunction_call_outputwith a storedfunction_callID, acustom_tool_callwith a storedcustom_tool_call_outputID, and ashell_callwith a storedshell_call_outputID all return 200 with the stored item, kind andcall_idincluded, from both providers. - Responses (
response-item-id-prefixes-*.yaml, t8-t11): OpenAI also replaces the input with the stored item; its 400 names the stored item'scall_id(No tool call found for shell call output with call_id call_seed_shell.).
Regressions:
item_id_prefix_recordings_admit_refuse_and_resolve_the_same_idsasserts that the resolved ID, type andcall_idare the stored item's, in both recordings.gateway_matches_openai_item_status_codes_and_bodiesreplays the OpenAI recording throughConversationHandleron SQLite and compares the resolved kind.stored_reference_resolves_to_the_stored_item_kindcovers the Responses path throughresolve_input_itemsagainst a SQLite store.
Note that fc_ was already shared by function_call and function_call_output before this PR, so the overlap was not introduced here; the PR extends the same OpenAI rule to custom and shell.
Signed-off-by: maral <maralbahari.98@gmail.com>
Signed-off-by: maral <maralbahari.98@gmail.com>
|
@franciscojavierarceo @tjtanaa while recording the |
tjtanaa
left a comment
There was a problem hiding this comment.
One follow-up finding on the new duplicate-ID handling. Based on source and cassette inspection; I did not run tests.
…fixes Signed-off-by: maral <maralbahari.98@gmail.com> # Conflicts: # crates/agentic-server-core/tests/cassettes/record_cassette.py
Signed-off-by: maral <maralbahari.98@gmail.com>
|
@franciscojavierarceo I have a commit to resolve conflict and address @tjtanaa comment but I dont have write access anymore |
Summary
Codex stamps
fco_IDs on thefunction_call_outputitems it builds, and the gateway refused them with400 invalid_valuebecauseInOutItem::admitaccepted onlyfc_. OpenAI accepts them. Probing OpenAI shows a call also accepts its output's prefix, socustom_tool_calltakesctco_andshell_calltakessho_, while an output keeps its own prefix.InOutItem::id_prefixes()now lists the prefixes OpenAI admits for each type, replacing the twoid_prefix()functions onInputItemandOutputItem; new IDs are still minted with the first one (fc_,ctc_,sh_, ...).Fixes #547.
Changes by API
/v1/responses) and Conversations (/v1/conversations,/v1/conversations/{id}/items)function_callandfunction_call_outputadmitfco_as well asfc_;custom_tool_calladmitsctco_;shell_calladmitssho_. Every other prefix and every minted ID is unchanged.OpenAI behavior (
store: false), which the gateway now matches:400 invalid_value)function_call,function_call_outputfc_,fco_xyz_,fcabc...custom_tool_callctc_,ctco_xyz_custom_tool_call_outputctco_ctc_shell_callsh_,sho_xyz_shell_call_outputsho_sh_Test Plan
POST /v1/conversations, which runs the same admission check); all 11 statuses match.cargo fmt -- --checkandcargo clippy --all-targets -- -D warningsare clean.cargo test -p agentic-server-core --test responses_api_test: 31 passed.cargo test -p agentic-server-core --lib item: 117 passed.