[PR #13832] fix(bash): make description parameter optional in bash tool #14833

Open
opened 2026-02-16 18:19:35 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13832

State: open
Merged: No


Summary

This PR fixes a critical bug where the bash tool's description parameter was marked as required but not exposed to the AI model, causing ALL bash commands to fail with a Zod validation error.

The Bug

When running any bash command (even simple ones like ls -la), the AI would receive:

Error: The bash tool was called with invalid arguments: [
  {
    "expected": "string",
    "code": "invalid_type",
    "path": ["description"],
    "message": "Invalid input: expected string, received undefined"
  }
]

This completely broke the bash tool - one of OpenCode's most fundamental tools.

Root Cause

In packages/opencode/src/tool/bash.ts, the description parameter was defined as:

description: z.string().describe("...")
//          ↑↑↑ Missing .optional() - treated as REQUIRED by Zod

However, this parameter was not included in the tool schema exposed to the AI model, so the AI had no way to know it needed to pass it.

The Fix

Made description optional and added fallback to params.command:

- description: z.string().describe("...")
+ description: z.string().describe("...").optional()

Added fallback values in 4 locations where description is used:

  • Initial metadata setup: params.description ?? params.command
  • Metadata updates during execution: params.description ?? params.command
  • Return value title: params.description ?? params.command
  • Return value metadata: params.description ?? params.command

Impact

Bash commands now work without requiring the description parameter
When description is not provided, it defaults to the command string
Backward compatible: existing code that passes description still works
Unblocks the bash tool - users can now run shell commands again

Test plan

  • Verified that description is now optional in the schema
  • Added fallback values for all usages of params.description
  • Ensured backward compatibility with existing callers
  • Minimal change - only what's needed to fix the bug

Fixes #13146

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13832 **State:** open **Merged:** No --- ## Summary This PR fixes a **critical bug** where the bash tool's `description` parameter was marked as required but not exposed to the AI model, causing **ALL bash commands to fail** with a Zod validation error. ## The Bug When running any bash command (even simple ones like `ls -la`), the AI would receive: ``` Error: The bash tool was called with invalid arguments: [ { "expected": "string", "code": "invalid_type", "path": ["description"], "message": "Invalid input: expected string, received undefined" } ] ``` This completely broke the bash tool - one of OpenCode's most fundamental tools. ## Root Cause In `packages/opencode/src/tool/bash.ts`, the `description` parameter was defined as: ```typescript description: z.string().describe("...") // ↑↑↑ Missing .optional() - treated as REQUIRED by Zod ``` However, this parameter was not included in the tool schema exposed to the AI model, so the AI had no way to know it needed to pass it. ## The Fix **Made `description` optional** and added fallback to `params.command`: ```diff - description: z.string().describe("...") + description: z.string().describe("...").optional() ``` **Added fallback values** in 4 locations where description is used: - Initial metadata setup: `params.description ?? params.command` - Metadata updates during execution: `params.description ?? params.command` - Return value title: `params.description ?? params.command` - Return value metadata: `params.description ?? params.command` ## Impact ✅ Bash commands now work without requiring the description parameter ✅ When description is not provided, it defaults to the command string ✅ Backward compatible: existing code that passes description still works ✅ **Unblocks the bash tool** - users can now run shell commands again ## Test plan - [x] Verified that `description` is now optional in the schema - [x] Added fallback values for all usages of `params.description` - [x] Ensured backward compatibility with existing callers - [x] Minimal change - only what's needed to fix the bug Fixes #13146 🤖 Generated with [Claude Code](https://claude.com/claude-code)
yindo added the pull-request label 2026-02-16 18:19:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14833