fix: system prompt tracing skips subsequent agents due to step counter not resetting
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- observability
Research direction
Start in packages/opencode/src/session/prompt.ts and inspect the loop around the step === 1 guard, including how agent switches update lastUser.agent. Trace a session that switches agents, then verify that each agent's system prompt is logged once when it first becomes active without changing tool execution behavior.
Written by the indexing model from the issue text.
Description
What does this PR do?
Follow-up from PR #287. The if (step === 1) guard in packages/opencode/src/session/prompt.ts traces the system prompt only on the first step, but the comment claims "Agent switches re-enter loop() with step reset to 0" — this is incorrect. The step variable is initialized once and increments continuously; it is never reset on agent switches.
Current behavior: Only the first agent's system prompt is traced. If a session switches agents mid-conversation (e.g. builder → analyst), the second agent's system prompt is never logged.
Expected behavior: Each agent's system prompt should be traced once when it first becomes active.
Possible fixes
-
Track the last-traced agent and re-trace when the agent changes:
if (step === 1 || lastUser.agent !== previouslyTracedAgent) { Tracer.active?.logSpan({...}) previouslyTracedAgent = lastUser.agent } -
Or fix the comment to accurately describe the current behavior (trace first agent only).
Priority
Low — tracing/observability only, no functional impact on tool execution or user experience.
- Dominant language
- TypeScript
- Stars
- 813
- Forks
- 134
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 62
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AltimateAI/altimate-code
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
AltimateAI/altimate-code#1323 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
AltimateAI/altimate-code#1288 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
AltimateAI/altimate-code#1285 ·
-
privacy: Altimate Base consent dialog no longer discloses persistent per-installation identifier Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
AltimateAI/altimate-code#1284 ·
-
Difficulty 2/5 Under an hour Newbie friendliness 72/100
AltimateAI/altimate-code#1283 ·
All issues in AltimateAI/altimate-code
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·