feat(resource): per-agent max_text_chars config + kb_diag_agent YAML align - #404
feat(resource): per-agent max_text_chars config + kb_diag_agent YAML align#404Million-mo wants to merge 1 commit into
Conversation
…align (#394) * feat(resource): per-agent max_text_chars config + kb_diag_agent YAML align ResourceConfig now accepts max_text_chars (default 10000, min 100) in agent YAML config. NativeAgent creates a per-agent ResourceCapability with the agent's max_text_chars instead of sharing the pool-level instance. ResourceCapability.__init__ gains max_text_chars parameter (backward compatible). Truncation suffix improved with guidance directing the model to use narrower URIs or paginated read tools. kb_diag_agent.yaml aligned with live knowledge_diag server v3.4.4: - Enabled search_kb (removed from disabled_tools) - Added get_doc_toc and read_chapter_page tool-schema-overlap rewrites - Added search_kb rewrite with methods (FULL/FAST/WIKI) param docs - Updated existing tool descriptions to reference page-based workflow Supersedes PR #393. * feat(mcp): resource subscribe-on-read wiring in McpServerCap Best-effort subscribe to resource URIs after successful read_resource() calls, enabling notifications/resources/updated for resources the agent has read. Tracked subscriptions are re-established on reconnect and cleaned up on disconnect. No-op for servers with subscribe:false (like knowledge_diag v3.4.4) — subscribe fails silently, read proceeds normally. Activates automatically when server enables subscription support. * fix(mcp): address PR #394 review — wire max_text_chars, fix broken test, consolidate truncation - Wire self._max_text_chars into read_mcp_resource (was hardcoded _DEFAULT_READ_TEXT_LIMIT) and use _truncate_text helper with guidance suffix - Remove dead _truncate_text static method from ResourceCapability (zero callers, old suffix format) - Add constructor validation: max_text_chars < 100 raises ValueError - Consolidate default constant: _DEFAULT_MAX_TEXT_CHARS in resource_resolver.py, aliased in resource_capability.py - Fix broken test assertion in test_resource_resolution.py to match new guidance suffix format - Add tests: max_text_chars validation, read_mcp_resource truncation with per-agent limit, suffix guidance text - Correct changelog: limit was previously hardcoded, not a pre-existing constructor param - Update capabilities/AGENTS.md: ResourceCapability is per-agent constructed, not registered at SESSION scope
Review — per-agent
|
|
Posted the synthesized review at #404 (comment). Summary of what I reviewed and found (verified against source, with specialist code + docs subagents): Code — should-fix
Docs — should-fix Plus nits (dead guard, constant duplication, private-name import, unbounded |

Replacement for #394 (original was merged but got caught in main rollback; #400 auto-merged into wrong base).
Per-agent
max_text_charsconfig for resource truncation + kb_diag_agent YAML alignment.10 files, +310/-47 — matches original #394 exactly.
Depends on #403. Review #403 first.