Skip to content

Commit d11400b

Browse files
phernandezclaude
andcommitted
docs(integrations): document the defensive getattr in the Hermes provider
Addresses the remaining review finding (deferred while #859 was open; now merged, so the hermes module is on main and the comment lands cleanly here). The two getattr sites read MCP SDK result/tool fields; `mcp` is an unpinned dependency (plugin.yaml), and its CallToolResult / ListToolsResult / Tool shapes have varied across SDK versions — so the defensive getattr is intentional, not the speculative kind CLAUDE.md warns against. Added constraint comments at both sites explaining why. No behavior change. `just package-check-hermes` passes (244 passed, 12 integration tests skipped without BM_INTEGRATION). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 0e67d00 commit d11400b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

integrations/hermes/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ def _extract_mcp_text(result: Any) -> str:
449449
Returns a JSON string for the agent. If the result is itself JSON, returns it
450450
as-is. Otherwise wraps the text in `{"text": "..."}` for downstream parsing.
451451
"""
452+
# The `mcp` SDK is an unpinned dependency (see plugin.yaml), and its result
453+
# shapes (CallToolResult, content blocks) have shifted across versions — read
454+
# these fields defensively with getattr rather than direct attribute access.
452455
is_error = bool(getattr(result, "isError", False))
453456
parts: list[str] = []
454457
for c in getattr(result, "content", None) or []:
@@ -594,6 +597,9 @@ async def _main(self) -> None:
594597
self._stop_future = asyncio.get_running_loop().create_future()
595598
try:
596599
listing = await session.list_tools()
600+
# Same unpinned-`mcp`-SDK reason as parse_result above:
601+
# ListToolsResult / Tool field shapes vary across SDK versions,
602+
# so read them defensively rather than by direct attribute access.
597603
self._tools_cache = [
598604
{
599605
"name": getattr(t, "name", ""),

0 commit comments

Comments
 (0)