fix(opencode): defer defaultAgent lookup in session summarize#36363
Open
1837620622 wants to merge 1 commit into
Open
fix(opencode): defer defaultAgent lookup in session summarize#363631837620622 wants to merge 1 commit into
1837620622 wants to merge 1 commit into
Conversation
/compact (POST summarize) always called Agent.defaultAgent() before falling back from the last user message agent. When default_agent is a subagent that call throws, so compaction fails silently even though the session already has a valid agent. Only resolve defaultAgent when no user-message agent is present. Closes anomalyco#29277
Author
|
Review ping 🙏
|
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 #29277
Type of change
What does this PR do?
/compact(andPOST /session/:id/summarize) silently fails whendefault_agentis configured as a subagent.Root cause (still on
dev):Agent.defaultAgent()throws"default agent X is a subagent"before the last user-message agent fallback is considered. The TUI often ignores the API error, so compaction appears to do nothing.Minimal fix: only resolve
defaultAgent()when the session has no user-message agent:When the session already has a valid agent (normal case after chatting),
/compactworks even ifdefault_agentis a subagent. Empty sessions still surface the config error.Source evidence
packages/opencode/src/server/routes/instance/httpapi/handlers/session.ts— eagerdefaultAgent()insummarizepackages/opencode/src/agent/agent.ts—defaultInfothrows whenmode === "subagent"How did you verify your code works?
defaultAgent()defaultAgent()unchangedAuthor
35034498+1837620622@users.noreply.github.com(GitHub-verified noreply)Checklist
Closes #29277)