Repository navigation
fix(agent): report approvals by status and log each tool call - #40
Merged
Merged
Conversation
- outcome: a routine's approval card reads by its status in the history
and in search_thread (pending: it waits for the owner; dismissed:
nothing was done; approved: done or failed), not as "Done".
- Each tool call is logged with its app, tool, kind, status and duration,
never its arguments, result or text: the model's calls, a confirmed
capture and an approved action, as docs/design/overview.md and AGENTS.md
state.
- Routine.last and lastOk are the last scheduled run's, as
docs/specs/routines.md says a run now moves neither; the schema, the
api comments and the web label ("Last scheduled") now say so.
- docs/design/overview.md names tools as porterd does (notes__read_note).
Fixes #35
Fixes #36
Fixes #38
Fixes #39
The model writes a call's function name and can put owner content in a made-up one. A tool call's log line now takes the app and the tool from the name only when the registry offers it; any other name logs as (unknown). Guarded by TestAToolNameTheRegistryDoesNotKnowIsNotLogged and recorded in .memory/corrections.jsonl.
bketelsen
approved these changes
Nov 13, 2026
4 tasks done
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
Fixes 4 sweep findings in 1 change set.
outcome(internal/agent/agent.go) described every card that was not a capture asDone: …. A routine's approval card that was still pending, or that the owner dismissed, reached the model as done throughsearch_threadand the history. Approval cards now read by status: pending (it waits for the owner's approval), cancelled (dismissed, nothing done), done (approved and done), failed (approved, but it failed). ADR-0004: nothing runs until the owner approves it.docs/design/overview.md(Logs) andAGENTS.mdrequire the app, the tool, the status and the duration. NowAgent.calllogs 1tool callline for each model call, withapp,tool,kind,statusandduration. The 2 calls that run when the owner acts on a card (a confirmed capture, an approved action) also log 1 line each. The level is Warn when the call failed. Arguments, results, card text, summary, detail and URL are never logged.Routine.lastandlastOkhold the last scheduled run (internal/routine/scheduler.go), anddocs/specs/routines.mdsays a run now moves neither. The schema (schema/rpc/activity.yaml),api/activity.go,web/src/api.tsand the web label (Last scheduled) now say so. No behaviour change.docs/design/overview.mdnamed toolsnotes.read_note. It now uses the names thattools.Namebuilds:notes__read_note,mail__draft_reply.Fixes #35
Fixes #36
Fixes #38
Fixes #39
Risk tier
Risk tier: 3. The PR touches L1 paths in
.github/risk-paths.json:internal/agent/agent.go(auth: the approval cards). The change is safe:callwraps the old body (renamedrunCall, unchanged) with a timer and a log line.outcomechanges only the text that describes a past approval card to the model. No rule on what runs, what becomes an approval, or which ids a change may take is changed.internal/agent/own.go(auth: the check that a card can be confirmed). The change is safe: it adds 1 log line after the existing call inConfirmand inapprove. The pending check, the argument handling and the call are unchanged.api/activity.go(auth: the callers each activity method admits). The change is safe: only the doc comments ofLastandLastOKchange. The types, the JSON names and the method admissions are unchanged.The log lines carry only the app id, the tool name, the card kind, the status and the duration.
TestEachToolCallIsLoggedWithoutItsContentchecks that no argument, result or refusal text reaches the log.Verification
make cigreen (host and nsl):make verify(gofmt,go mod tidy -diff, vet, golangci-lint 0 issues,go test ./...),make race, andmake web-check(tsc, vitest: 8 files, 98 tests).de8a438, rungit checkout 1f7185f -- internal/agent/agent.go internal/agent/own.go && go test ./internal/agent/. These tests fail on assertions:TestOutcomeOfAnApprovalFollowsItsStatus(pending and cancelled read asDone: …),TestTheSearchedHistorySaysAnApprovalWaits(search_thread lacks "waits for their approval"),TestEachToolCallIsLoggedWithoutItsContent(logged 0 tool calls, want 2) andTestCaptureWaitsForTheOwner(the confirmed append is not logged).web/test/activity.test.tsnow checks theLast scheduledlabel..memory/corrections.jsonlline added. The cross-review ofde8a438found that a made-up function name (an unknown tool, or a call whose arguments are not JSON) reached the log, and such a name can hold owner content. Since831b400,Agent.calllogs the app and the tool only for a name thatRegistry.Lookupoffers. Any other name logs as(unknown). Guard:TestAToolNameTheRegistryDoesNotKnowIsNotLogged. With only thecallchange reverted (scratch worktree at831b400,agent.gofromde8a438), the guard fails: "the log holds Secret_Plan_token_123 / Secret_Name_456 / Secret_789".Cross-review
1f7185f..de8a438: Not ready, 1 blocking finding (above). It found no other issue.de8a438..831b400: Ready, Blocking: none. Reviewed head:831b4001c57567ce01c0f3e0add044265b45bca5.