Skip to content

feat(agents): save after each tool call, cap the reading, keep the first save's nudges - #41

Open
spacedevin wants to merge 2 commits into
mainfrom
feat/agents-tool-saves
Open

spacedevin wants to merge 2 commits into
mainfrom
feat/agents-tool-saves

Conversation

@spacedevin

Copy link
Copy Markdown
Member
  • Save after each tool call. runAgentLoop (and so runPersistent) checkpoints after every finished call, not only at a round's end. LoopCheckpoint.toolResults holds the round's finished calls by call id ({ id, name, argsText, ok, summary, content }); resumeRun answers those from the checkpoint, so a tool is never run twice. Calls that never finished are still answered as interrupted.
  • Reading limit. requireAction: { maxReadRounds, readMessage }: after that many rounds of only read-only calls with nothing acted, the model gets readMessage (default DEFAULT_READ_NUDGE, also sent to onNudge) and its next model call has toolChoice: "required". Checkpointed as readRounds and mustCallTool, carried over a resume (ResumeState gains toolResults, readRounds, mustCallTool).
  • Fix: runPersistent's first record saved nudgesLeft: 0; it now saves the real starting count (initialNudges(requireAction)).

Tests: Tish smoke (VM and JS agree) and src/agents/__tests__/agents-tool-saves.test.ts.

…quireAction

A run cut off mid-round lost every finished call of that round: on resume they were answered as interrupted, and
the model ran them again, so an edit could land twice. Each finished call is now checkpointed at once in
`toolResults`, keyed by call id, and a resume answers it from there instead of running the tool again.

`requireAction.maxReadRounds` (with `readMessage`) tells a model that has only read for that many rounds to act,
and requires a tool call on its next model call. The count and the forced call are checkpointed (`readRounds`,
`mustCallTool`) and carry over a resume.
The first record was saved with `nudgesLeft: 0`, so a turn resumed before its first round ended got no nudges.
It now saves the count `requireAction` starts with.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant