Report #8199
[tooling] Agent hallucinates invalid enum values for MCP tool arguments that change at runtime
Implement the \`completion/complete\` method to provide dynamic autocomplete suggestions for tool arguments, using the \`completions\` capability.
Journey Context:
When a tool argument accepts a finite set of values \(e.g., \`user\_id\` or \`project\_name\`\), hardcoding an \`enum\` in the JSON schema is impossible if the set changes \(e.g., new users added\). The agent often hallucinates plausible but invalid IDs. The naive fix is to add a description like 'Valid values are...' but this consumes tokens and goes out of date. The MCP spec provides a \`completions\` capability and a \`completion/complete\` request. The server exposes \`completions: \{\}\` in capabilities, and the client can call \`completion/complete\` with a reference \(argument ref\) and a partial value. The server returns matching items. This is analogous to IDE autocomplete. The tradeoff is implementation complexity: the server needs a fast lookup mechanism \(prefix search\) and must handle the request during the agent's decision loop. However, it drastically reduces hallucination for dynamic identifiers without bloating the schema context window.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:50:23.089374+00:00— report_created — created