fix(opencode): preserve loop diagnostics in tool metadata#490
Conversation
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the metadata handling in packages/opencode/src/session/prompt.ts to use SessionDiagnostics.mergeMetadata when updating tool states, ensuring existing metadata is preserved and merged correctly. Additionally, a new test case has been added to packages/opencode/test/session/prompt-effect.test.ts to verify that the loop gate effectively stops repeated successful bash calls after metadata updates. I have no feedback to provide as there were no review comments.
Summary
Why
Bash updates
state.metadatawhile it streams output. That replaced the loop diagnostics attached ontool-call, so successful repeated Bash commands were invisible to the loop gate. In the #489 export, the samegit diffcommand ran 39 times without the expected reminder, block, or stop.This fixes the shared
Tool.Context.metadataboundary instead of special-casing Bash, so tool-owned display metadata and harness-owned diagnostics can coexist.Related Issue
Closes #489
Human Review Status
Pending. A human should make the final merge decision after reviewing the final diff and verification evidence.
Review Focus
SessionPrompt: new tool metadata such as Bash output should still update, whilediagnostics.loopanddiagnostics.failureremain intact.Risk Notes
Low implementation risk, but the touched boundary is shared by tools that call
ctx.metadata(). The focused tests cover Bash streaming metadata plus existing diagnostics, loop-gate, and Bash behavior.How To Verify
Screenshots or Recordings
Not applicable. This is session harness behavior with no visible UI layout change.
Checklist
dev, and my PR title and commit messages use Conventional Commits in English