Support per-tool MCP output limits (#41421)

## What changed

- Add a positive `output_token_limit` setting to each entry under an MCP server's `tools` configuration.
- Apply the most restrictive limit when plugin and user policies overlap, while keeping approval policy independent.
- Carry the effective MCP output budget in conversation history so tool output, post-tool hook responses, and resumed sessions use the same truncation limit.

## Testing

- Cover configuration parsing, serialization, schema validation, and plugin policy merging.
- Cover MCP output below and above the configured limit, post-tool hook responses, and session resume.

GitOrigin-RevId: d0beb4fca9ba6055d9e1d31c137373b465d50d61
This commit is contained in:
pakrym-oai authored and copyberry committed 2026-08-28 21:40:23 +00:00
1 parent 03147407e3
commit f742dabc6f
38 files changed
+487 -224

No files matched your search

+8 -2
View File
@@ -1966,7 +1966,7 @@
},
"McpServerToolConfig": {
"additionalProperties": false,
"description": "Per-tool approval settings for a single MCP server tool.",
"description": "Per-tool settings for a single MCP server tool.",
"properties": {
"approval_mode": {
"allOf": [
@@ -1975,6 +1975,12 @@
}
],
"description": "Approval mode for this tool."
},
"output_token_limit": {
"description": "Token budget for this tool's output, before the standard 20% serialization allowance.",
"format": "uint",
"minimum": 1.0,
"type": "integer"
}
},
"type": "object"
@@ -2990,7 +2996,7 @@
"additionalProperties": {
"$ref": "#/definitions/McpServerToolConfig"
},
"description": "Per-tool approval settings keyed by tool name.",
"description": "Per-tool policy settings keyed by tool name.",
"type": "object"
}
},