Repository navigation
fix(tracing): trace each agent's system prompt when the agent switches mid-loop - #1874
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…s mid-loop Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
Author
There was a problem hiding this comment.
🔍 Devin Review: 3 flags
Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
Contributor
🤖 Code Review — OpenCodeReview (Gemini) — No Issues FoundNo supported files changed. |
This branch has not been deployed
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.
Issue for this PR
Closes #291
Type of change
What does this PR do?
loop()inpackages/opencode/src/session/prompt.tslogged thesystem-prompttrace span only whenstep === 1. The comment claimed agent switches re-enter loop() with step reset, but they don't.plan_exitwrites a builder user message into the running session, and a newly queued request can name another agent. Both are picked up by the same loop run, whose step keeps counting up, so only the first agent's system prompt ever reached the trace.The loop now remembers which agent it last traced (
systemPromptTracedFor) and logs system-prompt whenever the resolved agent.name changes. Steps that keep the same agent still log it once, as before. Thebootstrapspan stays under step === 1, because it measures loop entry to the first generation. The misleading comment has been rewritten.How did you verify your code works?
test/session/system-prompt-trace-loop.test.tsdrives the real prompt loop against the test LLM server, with a recording tracer set as Tracer.active. It holds the first model reply, adds a plan request to the running loop, then releases the reply. It asserts that the system prompts traced are ["builder", "plan"] and that exactly one bootstrap span is logged.tsgo --noEmitin packages/opencode is clean, and the pre-push hook (bun typecheckand the tracker-leak scan) passed.Cost side effects
None. This logs one extra local trace span per agent switch. It adds no model calls, queries or resources.
Screenshots / recordings
Not a UI change. The only visible effect is an additional system-prompt span in /traces after an agent switch.
Checklist