fix(llm): tolerate wrapped workflow tool args#20756
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
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:
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. |
Issue for this PR
Closes #20757
Type of change
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.parsedirectly 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.tsfor: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