fix: return a schema-valid empty result from madt_api_call #849
No reviewers
Labels
No labels
breaking
bug
documentation
enhancement
epic
good first issue
help wanted
refactoring
resolution/duplicate
resolution/invalid
resolution/wontfix
security
severity/critical
severity/high
severity/low
severity/medium
status/abandoned
status/blocked
status/needs-decision
status/needs-info
status/needs-verification
testing
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sixfold-space/madtea!849
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-836-api-call-empty-structured"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
madt_api_callfailed with "has an output schema but did not return structured content" whenever its body was empty. The common trigger is a jq or template filter that matches nothing, and a 204 hits the same path. The tool declares a JSON output schema, and both empty-body branches inapiCallreturned a nil structured value, so the SDK rejected the result.The change:
CallResultinto the MCP result moved intoapiCallToolResultininternal/mcp/tools_api.go, so it can be tested on its own.{"result": ""}. It then takes the same path as a non-empty body. When a built-in-command tip applies, the tip rides as a second text block after the JSON block.One result changes for a caller. An empty-body result with a tip now has two content blocks and structured content, not one tip block.
TestAPICallNudge_EmptyBodyWithTipnow expects that shape.Tests:
apiCallToolResultis tested with an empty filter result, a 204 with a nil body, and an empty 200, each with and without a tip. Each result is checked against the tool's declared output schema.TestApplyJQand template rows lock the step that a filter which matches nothing returns an empty string../scripts/gate.shpasses on this commit.Closes #836
A jq or template filter that matched nothing, or a 204 response, gave an empty body. The tool then returned no structured content, but it declares a JSON output schema, so the client rejected the call with a protocol error. The result shaping now lives in apiCallToolResult. An empty body gives the empty envelope {"result": ""}. A built-in-command tip rides as an added text block after the JSON text block, as on the non-empty path. Refs #836