Skip to content

opencode run adds empty stop-turn after tool-calls completion #19208

@Leslie-ller

Description

@Leslie-ller

Description

When opencode run executes a prompt whose main work is a tool call, the parent session does not terminate immediately after the tool result completes.

Instead, the parent session performs one additional assistant turn and only then exits. In exported session data, this extra turn is an assistant message with:

  • finish: "stop"
  • empty text

This makes tool-driven runs feel like they linger after completion, even when there is no additional user-visible output to produce.

Plugins

No extra global plugins in the control repro. The repro uses a local project plugin only to provide the tool call target.

OpenCode version

1.2.27

Steps to reproduce

  1. Prepare a temp repo with a tool-call target available.
  2. Run:
    XDG_CONFIG_HOME="$cfgdir" /home/leslie/.openclaw/tools/node/bin/opencode run --print-logs -m github-copilot/gpt-5.3-codex \
      'Call ability_run to execute development/code-change with inputs {"task_id":"probe_medium4","objective":"Update API handler and response type","acceptance_criteria":"handler returns 201;response type includes message","affected_files":"src/api/handler.ts,src/api/types.ts","validation_command":"grep -q 201 src/api/handler.ts && grep -q message src/api/types.ts"}. After the tool result, stop immediately.'
  3. Export the parent session after the run completes.
  4. Observe:
    • runtime log still advances another parent-session prompt step before exit
    • exported session contains a final assistant message with finish: "stop" and empty text

Screenshot and/or share link

No share link. Local evidence was captured in a control repro log and session export.

Operating System

Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 GNU/Linux

Terminal

bash (GNU bash 5.2.21) under WSL2

Additional context

Expected behavior:

  • after the tool result completes, the parent session should exit immediately if there is no remaining text or tool work

Actual behavior:

  • parent session performs one extra assistant turn before exiting
  • in the control repro, the runtime log shows step=1, then step=2, then exiting loop
  • exported session structure is:
    • user
    • assistant with finish="tool-calls"
    • assistant with finish="stop" and empty text

This does not appear to corrupt tool output or workflow artifacts. The tool result is correct and the session exits cleanly after the extra empty stop-turn. The issue appears to be runtime completion semantics after tool-calls.

Possible fix direction:

  • if all tool calls are complete and the next assistant turn would produce no text and no additional tool calls, CLI could terminate immediately instead of emitting an extra empty finish="stop" assistant turn

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)windows

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions