Skip to content

Missing tool description (undefined) on a plugin tool causes ALL sessions to crash with "Expected string, got undefined at [description]" #42026

Closed

Description

@system1970

Summary

When a local plugin registers tools via ctx.tool.transform → tools.add({...}), and one tool is missing its required description string field, it does NOT just make that one tool unusable — it breaks every session and every message, including a trivial "Reply with exactly: SMOKE_OK" that never touches the tool. The whole chat fails to get a reply at all.

Environment

  • opencode version: 0.0.0-next-17288 (also reproduced on next-17190 / next-17194 / next-17276)
  • OS: Windows 10 (win32 x64)
  • Channel: next (npm global)
  • Active plugins: local plugin at ~/.config/opencode/plugins/opencode-mobile-use/index.ts

Reproduction

  1. Create a local plugin registering several tools via ctx.tool.transform, all with proper name + description + input + execute, except one tool that omits description entirely.
  2. Run any session: opencode2 run "Reply with exactly: SMOKE_OK".
  3. Result: the command exits non-zero with:
Error: Expected string, got undefined
  at ["description"]

In the daemon log the stack is:

Failed to drain Session Error: Expected string, got undefined at ["description"]
  at SchemaParser.js:142:15
  at ../ai/src/schema/messages.ts:244:88
  at ../ai/src/llm.ts:59:19
  at SessionModelRequest.prepare (../core/src/session/model-request.ts:218:27)
  at SessionRunner.callModel ...
  at SessionRunner.drain ...

Actual Behavior

Every session dies during SessionModelRequest.prepare — the request is built from the full message + entire tool catalog, and a single tool with description: undefined fails schema validation for the whole thing. The model is never even called. No reply is ever produced. The failure is silent from the user's perspective in the TUI — messages just stop getting answers.

Expected Behavior

  • At minimum, a missing description on one tool should NOT crash all sessions — it should be gracefully skipped or surfaced as a per-tool warning (opencode has precedent for this: "isolate invalid plugin tools during reload/materialize", e.g. PR fix(core): isolate invalid plugin tools during materialize #37934, fix(core): isolate invalid plugin tools during reload #35963).
  • Ideally opencode should validate plugin tool definitions at load/register time and emit a clear, actionable error naming the offending tool (phone_type) rather than an opaque Expected string, got undefined at ["description"] deep in schema parsing that gives zero indication which tool or field is broken.

Additional Context

  • The bug is trigger-happy on config edits: a developer editing a plugin's description strings can silently delete one field and take down their whole opencode install.
  • This took a long debugging session to pin down because the stack trace gives no tool name, and the symptom (all sessions failing to reply) looks like a model/provider/auth/version problem rather than a missing field on one tool.
  • Error message clarity is the main ask: name the offending field/tool. A missing required field on a tool should be isolated, not fatal to the entire session.

Activity

  1. github-actions commented on Aug 12, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is specifically about the missing description field triggering schema validation failure in SessionModelRequest.prepare (rather than the opaque tool WeakMap identity problem in #35963), it may warrant its own fix, but the underlying ask — isolate bad tools from crashing all sessions — is already tracked.

  2. opencode-agent commented on Aug 13, 2026

    @opencode-agent
    Contributor

    Addressed by #42117. Model-facing tool definitions are now schema-validated before the Location registry mutates; malformed registrations return a Tool.RegistrationError naming the offending tool and schema failure. Registration batches remain atomic, so one missing description cannot poison the catalog or break later Session request preparation. Focused registry regressions cover the failure path. Closing as resolved on the v2 branch.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions