AltimateAI / AltimateAI/altimate-code

fix: system prompt tracing skips subsequent agents due to step counter not resetting

Offen
#291 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
811
Forks
134
Ø Merge
3 T. 2 Std.
Gemergte PRs (30 T.)
50

Beschreibung

### 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

1. Track the last-traced agent and re-trace when the agent changes:
```typescript
if (step === 1 || lastUser.agent !== previouslyTracedAgent) {
Tracer.active?.logSpan({...})
previouslyTracedAgent = lastUser.agent
}
```

2. 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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.