Skip to content

Conversation

@salacoste
Copy link

Summary

This PR fixes two user-facing regressions observed in OpenCode sessions:

  1. Responses that only contain reasoning/tool output resulted in no visible final answer.
  2. Sessions with pending TODOs could loop indefinitely even when the user did not request continuation.

What changed

1) Final-response fallback for reasoning/tool-only replies

  • Detects assistant messages that finish without visible text but contain reasoning/tool parts.
  • Enqueues a synthetic user message and routes it through a hidden final agent with tools disabled.
  • Ensures a plain-text final response is returned.

2) TODO continuation loop guard

  • Adds todo_state tracking (paused/updatedAt/lastUpdatedMessageID).
  • Pauses automatic TODO continuation unless the user explicitly asks to continue.
  • Clears pause on todowrite updates and injects a short system guard when paused.

3) Supporting updates

  • Added documentation for both fixes.
  • Adjusted a Bun test to avoid test.concurrent (not supported by Bun).

Files touched (high level)

  • packages/opencode/src/session/prompt.ts
  • packages/opencode/src/session/llm.ts
  • packages/opencode/src/session/todo.ts
  • packages/opencode/src/tool/todo.ts
  • packages/opencode/src/agent/agent.ts
  • packages/opencode/src/agent/prompt/final.txt
  • packages/opencode/test/session/retry.test.ts
  • docs/changes-2026-01-07.md
  • docs/reasoning-only-fallback-plan.md
  • docs/todo-loop-guard.md

Tests

  • bun test (packages/opencode)
  • bun turbo typecheck (pre-push hook)

Notes

  • The TODO guard is server-side; UI changes are not required.
  • The fallback uses a hidden final agent with tools disabled to avoid recursive tool calls.

Handle reasoning/tool-only replies by routing through a final agent and disabling tools per message.
Pause automatic TODO continuation unless the user explicitly asks to continue, and track todo_state in storage.
Add documentation for both fixes and adjust a test to avoid bun test.concurrent.
Use a typed default todo_state to avoid union inference during typecheck.
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant