Repository navigation
fix(session): drop nameless tool calls on the request path too - #293
Zongwei9888 merged 1 commit into
Conversation
|
Thanks, this is a clean fix for the stored side, and we confirmed it:
One part is still open: the live session. The service keeps the session in memory between turns; What we'd like added:
For context, |
A call whose function.name is blank names nothing, and the provider rejects the whole request that carries one. The record boundary already dropped them on save and on rebuild, but AgentSession._history lives in memory between turns, so a live run kept sending the same poisoned list: the follow-up request in the same turn and every later turn were rejected until the process restarted. Every model request goes through AgentRunner._request_view, so the filter now runs there, right beside _drop_orphan_tool_results. It drops the nameless calls and drops an assistant message left with no text and no calls. It runs before the orphan pass on purpose: dropping a call orphans its tool result, and the pass that follows removes it, so calls and results still pair up. The predicate itself moves to core.agent_runtime.helpers.named_tool_calls, and core.sessions.transcript imports it instead of keeping its own copy, so the storage path and the request path agree on what "named" means. Tests: tests/test_session_transcript.py, 13 passed. The new one drives AgentSession with a provider that returns name="": it asserts the follow-up request of the same turn and every later request carry no nameless call, and that the poisoned turn and the turn after it both complete. Mutation check: with the two _request_view call sites disabled, the new test fails with "request 1 carried a nameless tool call"; restoring them turns it green. Also green: tests/test_agent_session.py (41 with the transcript file), test_context_window_overflow / test_session_compaction / test_context_isolation / test_context_note_sink (19). ruff 0.15.21 check and format --check clean.
8df55fb to
71e0251
Compare
|
Thanks for the precise read of the live path — you were right, and your reproduction is exactly what I see. The live session is covered now. The filter runs in One ordering detail worth flagging: it runs before One shared helper. The predicate is now The test you asked for. I checked the test actually bites: with the two Green: One open item I did not guess at: whether you also want the storage path to drop an assistant message that keeps its text but loses its only call. Right now it keeps the text and drops the call, which read as the safer half; say the word if you want it mirrored. |
|
Merged in 534e94e. Thank you. A session that could never recover once a nameless call got in is a real bug, and the live-path test is exactly what we asked for. On your open question: keeping the text and dropping only the call is right, so nothing needs mirroring. A closer review turned up two more things, fixed on top in 2e719c7 and 1b31b8d:
|
Add the news entry and changelog for the 2026-11-16 community batch (#289, #293, #303, #307) and fold the 2026-10-31 entry into the earlier updates. The three points under "What Deep means" now match the numbered parts of the framework figure, self-evolution is named as planned, and "Why DeepCode" no longer repeats them.
Summary
A tool call whose
function.nameis blank names nothing, and the provider rejects the whole request that carries one. This drops such calls at both boundaries that matter.Storage (already reviewed and confirmed on this PR).
core.sessions.transcriptdrops them on save and on rebuild, so a saved session resumes cleanly and the fingerprint change avoids re-saving it.Request path (this revision).
AgentSession._historyis kept in memory between turns, so dropping them on storage alone leaves a live run poisoned: the follow-up request in the same turn, and every later turn, were rejected until the process restarted. Every model request goes throughAgentRunner._request_view, so the filter now runs there._drop_orphan_tool_resultson purpose. Dropping a call orphans its tool result, and the orphan pass that follows removes it, so calls and results still pair up.core.agent_runtime.helpers.named_tool_calls, andtranscript.pyimports it instead of keeping its own copy, so the storage path and the request path agree on what "named" means.Changes
4 files, +261 / -13.
core/agent_runtime/helpers.py— newnamed_tool_calls(), the one shared predicate.core/agent_runtime/runner.py—_drop_nameless_tool_calls(), wired into_request_view(both the main path and the minimal-repair fallback).core/sessions/transcript.py— drop the local copy, import the shared helper.tests/test_session_transcript.py— the newAgentSessiontest.Tests
tests/test_session_transcript.py— 13 passed. The new test drivesAgentSessionwith a provider whose first response is a call withname="", then asserts:task_complete.Mutation check: with the two
_request_viewcall sites disabled, that test fails withrequest 1 carried a nameless tool call; restoring them turns it green. So it fails for the reason it exists.Also green:
tests/test_agent_session.py(41 with the transcript file), andtest_context_window_overflow/test_session_compaction/test_context_isolation/test_context_note_sink(19).ruff 0.15.21 checkandformat --checkclean. Rebased onto3dcb0fb4.Dependency note
None. One new helper plus its two call sites; no new runtime path beyond
_request_view.