Repository navigation
ADFA-7340 AI-Core: show the model its own native call when it wrote nothing - #188
davidschachterADFA wants to merge 7 commits into
Conversation
…othing When a natively calling backend's model called tools and wrote no prose, AgentLoop stored no assistant turn (Gemini rejects an empty part) and then added the results as a user turn. The Claude backend sends results as user text, not tool_result blocks, and merges same-role turns, so the next request held the user's question with the results appended, and nothing showing the model had made the call. It asked for the same call again, and AI Core ended the run without an answer (ADFA-7186's symptom; seen with read_sql_template and list_databases on the Note 20, ADFA-7302 and ADFA-7300). Such a reply now gets an assistant turn naming its calls in plain words, "Calling <tool> with key=value.", from agent_loop.yml's new bare_call (CALLS: each value on one line, cut to 60 characters). It is never empty, and never a <tool_call> envelope, which would invite text-mode calls. The terminal tool alone adds none, as the run ends there; a reply with prose keeps its prose as before. New tests: AgentLoopBareCallTest (4) and two in ToolResultsPromptTest. With the new block in AgentLoop removed, the bare-call and the repeat test fail with the history [USER, USER, ASSISTANT] instead of the model's turn before its results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
A backwards-compatible fix: PATCH. addons #183 also takes 3.7.2; whichever of the two merges second takes the next version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…ence
The answer review (ChatViewModel.reviewAnswer), the second request for a
reply that holds code, removes from the draft whatever its evidence does
not hold. Its evidence was runToolLog, built by AgentActivity.logEntry for
the exported chat, which keeps a successful tool's output only for web
tools so that an export does not copy the project. So for every MCP,
contributed or project tool the review saw only "<tool> completed". On the
Note 20 with AI Core 3.7.2 (ADFA-7340 comment 41694), the model's answer
held the rendered SQL from read_sql_template, and the review removed it:
"The draft's SQL ... doesn't appear in anything the tool returned".
The review now gets its own evidence, runEvidence, from the new
AgentActivity.evidenceEntry: every call with its output, clipped as a web
result is, the review still capping the total at EVIDENCE_CHARS. This is
what PromptVariables.EVIDENCE already documents ("What the run's tools
returned, verbatim"). The exported chat keeps logEntry unchanged.
New tests in AgentActivityTest (3). With evidenceEntry made to return
logEntry, the output test fails with "... completed" and no output.
ChatViewModel's wiring has no view-model test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…ence The answer review cut its evidence at 60,000 characters from the end, so after a few large outputs the newest calls, which the draft quotes, were dropped and the review stripped the quoted text. It now drops the oldest whole entries and puts a first line saying how many were left out. A native reply with prose and calls stored only its prose, so the model could still repeat the call. It now stores the prose, a blank line and the call text; text-mode replies, whose text already holds the call, are unchanged. The call turn is stored only when the batch runs (or a repeat's answer prompt is sent), so a run ended by the progress guard no longer saves a call with no results. The rendered call text lists at most 10 calls and 10 arguments per call, builds its whitespace Regex once and cuts values by code point. Adds tests for these, for the real bareCall wiring in ChatViewModel, and for the evidence lifetime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…all text An evidence entry over the cap alone was cut under a "[0 earlier tool outputs were left out]" line. Evidence that fits now has no marker, and a cut says so, with the count of omitted outputs when both happen. The review located the draft's history turn by its prose alone, which no longer matches a native reply stored as prose, a blank line and the call text. The match now accepts that form and keeps the call text when it writes the correction back. Adds tests for both, for the start-of-run evidence clear, and for prose plus a native call reaching the next turn with the shipped wording. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
|
@hal-eisen-adfa Two new commits since you were asked to review (David, 2026-11-28), answering an independent review of this PR: 98944f3 and 92c7858. The description's "Review fixes" section lists them. In short:
1,430 AI Core tests, |
davidschachterADFA
left a comment
There was a problem hiding this comment.
Review of #188 at 92c7858278. Draft, base main; checked at this head.
IMPORTANT
- plugins/AI-Core/src/main/kotlin/com/itsaky/androidide/plugins/aicore/viewmodel/AnswerReview.kt:69 - Newest-first evidence eviction drops the required web_search result once project tool outputs (now kept whole) pass 60k, so the review strips or unverifies sourced versions
Verdict: COMMENT. This PR is authored by the account posting the review, and GitHub refuses APPROVE and REQUEST_CHANGES on your own PR. Severity rules: CodeOnTheGo REVIEW.md and CLAUDE.md (a ticket moves to QA with no outstanding critical, high or medium findings); addons has no written rule, so the default applied.
Generated by Claude Code
| ENTRY_SEPARATOR.length * (texts.size - from - 1) | ||
| if (size(0) <= EVIDENCE_CHARS) return texts.joinToString(ENTRY_SEPARATOR) | ||
| var first = 0 | ||
| while (first < texts.size - 1 && markerFor(first, false).length + ENTRY_SEPARATOR.length + size(first) > EVIDENCE_CHARS) { |
There was a problem hiding this comment.
IMPORTANT: evidenceText now drops the oldest entries first, and that is usually the web search, so the review can lose the only source for the draft's versions.
A run that must search first (VerificationPolicy: code in the message, "latest version", review of attached files) puts web_search first in runEvidence (about 12,000 chars). evidenceEntry now keeps every project tool's output, each read_file page about 4,000 chars. About 12 later reads push the total past EVIDENCE_CHARS, and the search is dropped. answer_review.yml then has the review mark every version not found in the evidence as unverified, or remove its credit to a search. Before this PR, project entries were one line and joined.take(60000) kept the search. Reproduced: one web entry plus five 12k entries gives "[2 earlier tool outputs were left out to fit.]" and no search text.
Always keep the WebAccess.TOOL_NAMES entries, and drop the oldest project outputs first.
Generated by Claude Code
…ce is cut Cutting the review's evidence by age dropped a web search once a run had read about a dozen files after it, and the review then marked versions it could no longer find as unverified. Each entry now carries whether AgentActivity keeps its output in full (a web tool's or a failure's, the rule logEntry already used), and the oldest project outputs are left out first. Only when those alone exceed the cap do the oldest web or failed outputs go. Order and the first-line marker stay; the marker no longer says "earlier", since a newer file read can be the one dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
|
@hal-eisen-adfa One more commit since my last note: ee9201b, from a review by David's cloud session (ADFA-7131 comment 41723). With every tool's output kept as evidence, the 60,000-character cut dropped the oldest first, so a web search made before many |
About five web results fill the evidence budget alone, and the project output read after them was then the first thing dropped, which could strip a rendered SQL template from the answer again. The newest entry is now outside the drop order whatever its kind; of the older entries the oldest project outputs still go first, then the oldest web or failed ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
|
@hal-eisen-adfa One more commit: 9d4e81b, from the cloud session's re-check (ADFA-7131 comment 41724). The answer review's evidence never drops the newest output now, so about five large web results can't push out the rendered SQL the answer quotes. 1,433 AI Core tests, |
…a bare native call The comments said AI Core stores no assistant turn "for a reply with no text and no call", which implies a reply that is only a native call is stored. On AI Core without ADFA-7340 (addons #188) it is not: the loop stores nothing for blank text and then adds the tool results as a user turn, which is the most common run of same-role turns. Both comments now say so, and that AI Core from ADFA-7340 on stores a turn naming the call. (Review on addons #191, ADFA-7131 comment 41750.) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
ADFA-7340
What: when a natively calling backend's model calls tools and writes nothing, AI Core now stores an assistant turn naming those calls, so the model sees on its next turn that it made them. Before, it often asked for the same call again, and AI Core ended the run without an answer. That was ADFA-7186's symptom, seen with the SQLite debugger's
read_sql_templateandlist_databaseson a Note 20 (ADFA-7302, ADFA-7300).Why it happened:
AgentLoopskipped the ASSISTANT turn for a native call with no prose, because Gemini rejects an empty part, and then added the results as a USER turn.tool_resultblocks, and merges same-role turns.ClaudeRequestBuilderTest.givenToolResultsAsUserTurns_whenMapped_thenConsecutiveUserTurnsAreMergedshows that merged message.The change (c3eed33):
agent_loop.yml's newbare_call. In itsCALLSvalue, each argument is on one line and cut to 60 characters, since a file's content can be long.<tool_call>envelope, which would invite the model to write its next call as text.bare_callandCALLS.The answer review's evidence (b745df4):
runToolLog.AgentActivity.logEntrybuilds that log for the exported chat, and it keeps a successful tool's output only for web tools.runEvidencefrom the newAgentActivity.evidenceEntry: every call with its output, clipped as a web result is, withinEVIDENCE_CHARS. That's whatPromptVariables.EVIDENCEalready documents. The exported chat is unchanged.Review fixes (98944f3, 92c7858): from an independent review of this PR, each re-checked.
textdiffers from itshistoryText.EVIDENCE_CHARS, in order, with a first line saying how many were left out, and whether the newest was cut to fit. Before, the cut kept the oldest, so a long run lost the output the draft quoted.From the cloud session's review (ee9201b; ADFA-7131 comment 41723, IMPORTANT): with every tool's output kept as evidence, the 60,000-character cut dropped the oldest first, so a web search made before about a dozen
read_filepages was pushed out and the review marked versions unverified. Now web and failed outputs are always kept (one rule,AgentActivity.keepsFullOutput, shared withlogEntry), and the oldest project outputs are dropped first; the first line says how many were left out. 9d4e81b (41724): the newest output is never dropped, whatever its kind, so five large web results can't push out the rendered SQL the answer quotes; it's cut only if it alone passes the cap.Version (dab848d): 3.7.2, versionCode 13. addons #183 also takes 3.7.2, so whichever of the two merges second takes the next version.
Tests:
AgentLoopBareCallTest(4): a bare call is stored as the model's turn before its results; prose stays the turn; a bare answer adds none; a bare repeat is shown before the prompt that asks for the answer.ToolResultsPromptTest: the wording, and a long argument cut to one short line.AgentActivityTest: a contributed tool's output is kept as evidence, a long output is clipped, and a failure keeps its details. WithevidenceEntrymade to returnlogEntry, the output test fails with "... completed" and no output.ChatViewModel's wiring ofrunEvidencehas no view-model test.assemblePluginandaddons checkpass, apart from the flakyChatViewModelCompactionTest.givenARunThatOverflowed_whenRetried_thenTheHistoryIsSummarizedFirstWhateverItsSize. It failed in 3 of 8 runs here and in 1 of 8 on dab848d, it runs no tool, and addons ADFA-7249 | AI-Core: fix the races in three ChatViewModel test classes #176 (ADFA-7249) fixes this class's waits. At dab848d: 1,401 tests pass.AgentLoopremoved, the bare-call and repeat tests fail with the history[USER, USER, ASSISTANT].AgentLoopBareCallTestadds prose with one and with several calls, a text-mode reply, several bare calls, a terminal tool beside real calls, and the cycle, repeat and second-repeat endings.AnswerReviewTestadds the order, the cap, the markers and the correction that keeps the call text.ToolResultsPromptTestadds the call and argument limits and a surrogate pair at the cut. The newChatViewModelBareCallTestruns the shipped wording through the real wiring, with and without prose, and checks the evidence is cleared at a run's start and end. With the fixes reverted, 14 of the 54 targeted tests fail, and each later fix has its own failing test.assemblePluginandaddons checkpass.assemblePluginandaddons checkpass; the new test (five large web outputs, then a small rendered SQL) fails with the newest entry back in the drop order. One test (givenWebOutputsAloneOverTheLimit_...) moved its small project entry from newest to oldest, so it no longer shows the project-first rule alone;givenAWebSearchThenManyLargeFileReads_...still does (left as is).assemblePluginandaddons checkpass. The two new evidence tests (a web search then 12 large reads; web outputs alone over the cap) fail with the old drop order.Device (Note 20, AI Core 3.7.2 at dab848d, ADFA-7302's
read_sql_templatequestions; ADFA-7340 comment 41694):Device at b745df4 (ADFA-7340 comment 41697): verified.
-- notes.db: Room schema matches, the row counts and theordersline with:idin C1,Room schema differs or is not exportedwith the schema hash changed in C4, andschema_matches=truein C2.database, which failed. AI Core then showed its stock "the last action failed" message. That's outside this PR (ADFA-7318).Not yet on a device: the review fixes, 98944f3, 92c7858, ee9201b and 9d4e81b. The Note 20 run is next.
Considered and not done: sending real
tool_use/tool_resultpairs to native backends. That's more correct, but it changes AI Core and every native backend (Claude, OpenAI, Gemini); David chose this smaller fix.🤖 Generated with Claude Code
https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn