Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/opencode/src/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ export namespace SessionPrompt {
let compactionCount = 0
let sessionAgentName = ""
let sessionHadError = false
let tracedAgent = ""
let emergencySessionEndFired = false
const emergencySessionEnd = () => {
if (emergencySessionEndFired) return
Expand Down Expand Up @@ -728,18 +729,18 @@ export namespace SessionPrompt {
system.push(STRUCTURED_OUTPUT_SYSTEM_PROMPT)
}

// altimate_change start - trace system prompt once per loop() call.
// The system prompt is functionally identical across steps within a single
// loop() invocation (same agent, same environment). Agent switches re-enter
// loop() with step reset to 0, so each agent's prompt is traced separately.
if (step === 1) {
// altimate_change start - trace system prompt once per agent.
// The step counter is never reset on agent switches, so we track the
// last-traced agent to ensure each agent's system prompt is logged.
if (step === 1 || agent.name !== tracedAgent) {
Tracer.active?.logSpan({
name: "system-prompt",
startTime: Date.now(),
endTime: Date.now(),
input: { agent: agent.name, step },
output: { parts: system.length, content: system.join("\n\n") },
})
tracedAgent = agent.name
}
// altimate_change end

Expand Down
Loading