Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
Round-1 review at 810edb5 merged onto b466fb795, the current main. CI: the PR is a draft, so go and integration were skipped. They run at gh pr ready.
Local runs: go test ./internal/agent/ passed. -race -count=3 on the new tests passed. The integration suites TestAppHooksSuite, TestSessionToolsSuite and TestChannelTypeTurnSuite passed. gofmt and vet are clean. The author's 6 mutants are all killed. I added 4 mutants and 1 survived (R1.1).
Checked and sound:
lastWriteris written only inrespondTurnand read only inrequesterLocked, both undera.mu. The lock scope did not change.- A user-token session never carries
WithWriter, so its requester is the same as on base. The control test passes. WithWriteris set only for a channel type other thanagent(threadhooks.go:176), so thread channels and configs withoutchat_channelsare unchanged.- The author's two questions (thread channels, per-user connector connections) are about code this PR does not change. Neither one is a hole this PR opens.
Verdict: request changes, for R1.1 (Should fix).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…participant Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
Delta review at 4c7e8090e (last reviewed 810edb5c2). The head is current main (175bce1f1) merged in, so the tested tree is the head. Verdict: GO.
Round 1 findings:
- R1.1 (a second tool round of a written turn): fixed.
TestEveryToolRoundOfAWrittenTurnIsForWhoeverWroteItpasses. Witha.lastWriter = writer{}added aftera.toolRounds++inrespondAfterToolit fails (round 2 expected{anya-1 Anya}, got{}). - R1.2 (
lastWritercomment untrue for other turn starts): fixed. The comment now says the field is cleared whereverlastParticipantis set for a heard or new turn, and each of those sites clears it.TestAnAdoptedSpeculationDoesNotKeepTheLastWriterfails when the reset atspeculate.go:297is removed (expectedRequester{}, got{anya-1 Anya}). - The six other resets (
agent.go:1878,agent.go:1945,native.go:92,native.go:110,native.go:327,native.go:566) have no test of their own. I removed all six together and the whole./internal/agentpackage still passes, as the fixer said. I do not block on that:lastWriteris written in one place,agent.go:2485inrespondTurn, which only the cascade paths reach.RespondTosends a native agent torespondNativefirst, and that reads no writer, so on a native agentlastWriteris never non-zero. The fournative.goresets can change no state.- The two
agent.goresets need audio transcripts on an agent that also took a writer turn. A writer comes only from the router-opened text session of achat_channelsconfig. - Each reset zeroes a field on the line group that already refreshes the participant. A missing one cannot give a hosted call a name it does not get today.
Checks on the merged tree, with my own test database:
gofmtandgo vet(also with-tags integration) are clean.go test ./internal/agentpasses.go test -tags integration -p 1 ./internal/api -run 'TestAppHooksSuite|TestSessionToolsSuite|TestChannelTypeTurnSuite'passes.- The two new tests pass under
-race -count=20and-cpu 1 -count=30. - Every new reset sits inside an existing
a.musection, so no lock scope changed. - CI: the PR is a draft, so
goandintegrationskip. CodeQL, the Analyze jobs and GitGuardian pass. - No new findings.
Details: reviewer-2.md in the ledger directory.
Why
In a channel that an agent config answers through
chat_channels(a team's group channel), a call of a tool that the app's backend hosts (a dispatch worker) named no user. A backend that acts for "the user who asked" (tools.ToolCallContextFrom(ctx).User.ID) got an empty id and had to refuse. The same tool in a session opened with the user's token carried the user (AI-3464, live check on staging).Cause:
respondTurnput the writer fromagent.WithWriteronly into the turn'ssaidparticipant (internal/agent/agent.go:2463-2466on b466fb7).lastParticipantstayed the typed caller, which has no user id (agent.go:2479).requesterLocked(internal/agent/requester.go:27-35) then found nobody. The Router opens achat_channelssession with noCaller, sohostedRunner.Runsent no user (internal/session/hosted_tools.go:131-135).How it works
This reuses the writer that
agent.WithWriter/WriterOfalready own (AI-3154 approvals go toWriterOf). It adds no new path. The same requester also reaches a session's client tools (internal/session/tools.go:147).chat_channels, Anya writes (alwaysormentioned)useruserValidation
AgentSuite/TestAToolAskedForInAWrittenTurnIsForWhoeverWroteItAppHooksSuite/TestAHostedCallInAChannelTypeAnsweringMentionsIsForEachTurnsWritertool_callhas no user inanswer: mentionedusernil)AppHooksSuite/TestAHostedCallInAChannelTypeAnsweringEveryMessageIsForEachTurnsWriteranswer: alwaysusernil)SessionToolsSuite/TestAHostedCallInASessionOpenedWithAUsersTokenIsForThem(control){"id": <user>}Mutations (one script, every changed line): writer fallback removed, writer never kept, writer kept only when set (stale), writer after sender, writer over a heard participant, writer name dropped. A test kills each one.
AppHooksSuite.SetupSuitenow callsmanager.HostTools(dispatch), ascmd/router/main.go:1375does, so its sessions offer what a worker hosts.🤖 Generated with Claude Code