docs: fix Mode C handler example — cwd-based agent resolution#694
Merged
Conversation
The /proc/self/cmdline approach is unreliable because shell hooks run as child subprocesses whose cmdline is the handler script, not the gateway process. This caused agent name resolution to fail when hooks were invoked from asyncio contexts (e.g., session expiry watcher). Changes: - Replace /proc/self/cmdline with cwd-based resolution from payload - Dynamically resolve agent per invocation (not at module load time) - Remove hardcoded UTEKE_BIN path check (assume uteke on PATH) - Remove cron session skip (handler-level concern, not docs example) - Pass agent name to recall function explicitly
🔍 Cora AI Code Review❌ Blocked — critical issues found. 🔴 Error (1)
Review powered by cora-cli · BYOK · MIT |
Cora review: docstring claimed 'Priority: cwd > HERMES_PROFILE env > fallback' but code only checks cwd then returns 'default'. Fix docstring to match actual behavior.
| gateway. Use the cwd payload field (always set by Hermes) instead. | ||
|
|
||
| Falls back to "default" if cwd is empty or resolution fails. | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the Mode C handler example in Hermes integration docs.
Problem
The example handler used
/proc/self/cmdlineto resolve agent name. This is unreliable because:AGENT = _resolve_agent_name()resolves once at import time, not per invocationUTEKE_BINpath doesn't work for users who install uteke differentlyThis caused agent name resolution failures when hooks were invoked from asyncio contexts (e.g., session expiry watcher).
Changes
/proc/self/cmdline→ parse-pflagcwdfrom Hermes wire protocol payloadAGENT = _resolve_agent_name()(module-level)_resolve_agent_name(raw.get("cwd", ""))UTEKE_BINpath check + hardcoded fallback"uteke"(assumes on PATH)The cwd-based approach is battle-tested across all 6 production agents and documented in the Hermes hook injection reference.
Files
docs/integrations/hermes.md— Mode C handler example script