Skip to content

fix(llm): tolerate wrapped workflow tool args#20756

Closed
sudorest wants to merge 2 commits into
anomalyco:devfrom
sudorest:fix/workflow-tool-args-json
Closed

fix(llm): tolerate wrapped workflow tool args#20756
sudorest wants to merge 2 commits into
anomalyco:devfrom
sudorest:fix/workflow-tool-args-json

Conversation

@sudorest

@sudorest sudorest commented Apr 2, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #20757

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes a workflow edit-writing failure where GitLab workflow tool calls could surface unterminated string JSON parse errors before the tool ran.

The workflow executor was calling JSON.parse directly on the raw tool args string. For edit flows, some model outputs can wrap the object payload in fenced JSON or surrounding prose. This change parses object-shaped tool args more defensively in that workflow path, still rejecting malformed or non-object inputs with a clear error.

How did you verify your code works?

I added focused regression coverage in packages/opencode/test/session/llm.test.ts for:

  • strict JSON tool args
  • fenced JSON tool args
  • prose-wrapped JSON object args
  • malformed unterminated-string args
  • non-object JSON args

The original broader workflow-path test was replaced with direct parser coverage because the integration version relied on global monkey-patching and a fake workflow model shape, which was brittle in CI.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 2, 2026
@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Apr 2, 2026
@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@rekram1-node

Copy link
Copy Markdown
Collaborator

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix unterminated string errors in workflow edit tool args

2 participants