Skip to content

Tool execution aborted when tool call is truncated (empty input) #13102

Description

@cjmayoral

snippet-01-tool-aborted.json
snippet-02-message-finish-length.json
snippet-03-session-created.log
snippet-04-llm-model.log
snippet-05-session-cancel-1.log
snippet-06-session-cancel-2.log

Tool execution aborted when tool call is truncated (empty input)

Summary

During session "Resumen T84 antes de continuar" (ses_3b7971163ffexUgX5mjSgXDfWQ), several tool calls ended with Tool execution aborted. One concrete instance shows an edit tool call with empty input ({}) that immediately fails. The same assistant message ended with finish: "length" (output length limit), which suggests the tool call may have been truncated before arguments were fully emitted. This looks like a truncation/cancel edge case rather than an LLM transport failure.

Environment

  • OpenCode version: 1.1.49
  • OS: Windows
  • Model: claude-opus-4-6 (azure-anthropic)
  • Session title: "Resumen T84 antes de continuar"
  • Session ID: ses_3b7971163ffexUgX5mjSgXDfWQ

Evidence (sanitized excerpts)

The following log snippets are attached in snippets/ (redacted paths):

  1. snippet-01-tool-aborted.json — tool call aborted with empty input

  2. snippet-02-message-finish-length.json — same message finished due to output length

  3. snippet-03-session-created.log — session creation (OpenCode 1.1.49)

  4. snippet-04-llm-model.log — model/provider info

  5. snippet-05-session-cancel-1.log — user cancellation (expected behavior)

  6. snippet-06-session-cancel-2.log — user cancellation (expected behavior)

Notes / Hypothesis

  • The tool call is emitted with empty input and immediately aborted.
  • The corresponding assistant message ended with finish: "length", which is consistent with output truncation.
  • This suggests OpenCode may attempt to execute a tool call even when its arguments are incomplete due to truncation.

Expected behavior

If a tool call is truncated (missing or empty input), OpenCode should either:

  • retry the model to complete the tool arguments, or
  • skip tool execution with a clearer error (e.g., "tool call incomplete due to output length"), instead of Tool execution aborted.

Questions for maintainers

  • Is there a guard that detects incomplete tool call payloads before execution?
  • Is there a known interaction between finish: "length" and tool call emission that can cause empty-input tool calls?

Related issues

Activity

github-actions commented on Feb 11, 2026

@github-actions
Contributor

This issue might be related to existing issues addressing similar tool execution failures:

Your report provides additional detail about the truncation → empty input → abort mechanism. The maintainers may consolidate findings across these issues.

TheOrdinaryWow commented on Mar 17, 2026

@TheOrdinaryWow

same here

onurdemircan-softtech commented on Mar 23, 2026

@onurdemircan-softtech

I'm also running into this issue with a local model served via vLLM . I'd like to propose a practical approach for handling this case.

When the model is streaming a tool call (e.g. write), the argument chunks come in incrementally:

argument: "{"
argument: "\"filePath\": \"src/app.ts\","
argument: "\"content\": \"import express..."
argument: "...more code chunks..."
argument: "...more code chunks..."
← truncated here, finish_reason: "length"

At this point, the tool call arguments are incomplete JSON, so OpenCode aborts the entire tool call and the partial output is lost.

Instead of aborting, OpenCode maybe should:

Detect that finish_reason is "length" while a tool call argument is still being streamed (i.e. the JSON is unclosed).
Synthetically close the incomplete JSON argument — append the necessary closing characters (", }, etc.) to make the partial argument valid.
Treat it as a completed tool call internally, but do NOT execute it (don't actually write the file).
Show a warning to the user with the partial content that was generated so far, something like: "Tool call truncated due to output token limit. Partial content below:"
Stop the agentic loop and hand control back to the user.

This way, the user can see exactly what was generated before truncation and decide how to proceed — whether to ask the model to continue from where it left off or retry with a different approach
The key insight is: don't discard the partial streamed data. The model already generated useful content; OpenCode just needs to gracefully capture it instead of treating truncation as a fatal error.

lucamaia9 commented on Apr 2, 2026

@lucamaia9

same issue here:

~ Updating todos...
Tool execution aborted
""
assigned and unassigned on Apr 26, 2026

github-actions commented on Jun 26, 2026

@github-actions
Contributor

To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions