Repository navigation
feat: log the agent's tool calls while it runs - #31
Conversation
🦋 Changeset detectedLatest commit: c5e42cd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 57 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
The SDK streams a tool_call event for every tool the agent uses, but nothing turns one into text a person can read. A lookup table from tool name to its target argument gives each call a short line such as 'read src/index.ts', collapses whitespace, caps long arguments, and prints each call once even though the SDK reports it several times.
The step log printed three lines and then nothing until the run ended, so a workflow author could not tell whether the agent was working, stuck, or reading the wrong files. The runner already receives a tool_call event for every tool, so it now prints one line per call as it starts.
…esult The local stream never sets a tool_call status of "error"; a failed tool shows up as a completed event whose result has status "error", so the failed line could never print. Running events also include partial updates the server sends while the model is still writing the arguments, so the first one can carry a cut-off path or command. Logging the completed event fixes both, and no call needs remembering any more.
2bd6d15 to
c5e42cd
Compare
|
Deployment failed for project cursor-action with the following error: Learn More: https://vercel.com/pungrumpy?upgradeToPro=build-rate-limit |
Description
While the agent works, the step log shows the working directory, the model, and the permissions, and then nothing until the run ends, which can take many minutes. You cannot tell whether the agent is reading the right files or looping, and after a bad answer you cannot see what it looked at.
The SDK already streams a
tool_callevent for every tool the agent uses, and the action was throwing them away. It now prints one line per call when the call finishes, such asread src/index.ts,grep TODO, orshell bun test. A call whose tool reports an error ends infailed. A shell command that exits non-zero still ran, so it does not. There is no new input. Arguments are cut to 160 characters, and file contents, edit bodies, and tool results are never printed.Lines are printed on completion rather than at the start because the stream also reports a call as running while the model is still writing its arguments, so a start line could show a cut-off path or command. The cost is that a long shell command appears when it finishes.
The target of each tool comes from a lookup table checked against the arguments the SDK actually sends for each tool. A tool it does not know prints its name alone.
Related Issues
None.
Checklist
.github/–only changes).github/–only community or template updates)Screenshots (if applicable)
None.
Additional Notes
Proof: 13 tests in
__tests__/progress.test.tsand one runner test (a call reported as running and then completed is logged once and stays out of the answer). The event lifecycle was traced in the@cursor/sdk1.3.1 bundle: running for partial and started updates, one completed event per call with the full arguments, and failures only inresult.status. A live smoke run on Ubuntu, Windows, and macOS (run 43787687683) printedshell printenv INPUT_API-KEY >/dev/null && echo SET || echo UNSETin the step log for the agent's one shell call.