Skip to content

docs: add Mode C pre_llm_call shell hook integration - #490

Closed
ajianaz wants to merge 2 commits into
developfrom
docs/pre-llm-call-hook-mode
Closed

ajianaz wants to merge 2 commits into
developfrom
docs/pre-llm-call-hook-mode

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds documentation for Mode C — the lightest Hermes integration option that uses pre_llm_call shell hooks for automatic uteke recall injection.

Changes

  • integrations/hermes.md: New Mode C section with:

    • Architecture diagram (message → hook → uteke recall → context injection)
    • Full handler.py reference implementation
    • config.yaml registration example
    • Comparison table: Mode A vs B vs C
    • Race safety explanation (subprocess stdout, no shared state)
  • getting-started.md: Updated Hermes callout to reference all 3 integration modes

Test

  • Handler tested live: produces {"context": "..."} correctly
  • All 6 agents already deployed with this hook (cto, kai, cfo, novelist, sosmed, badsector)
  • Race-safe: verified no shared file writes, per-call subprocess invocation

ajianaz added 2 commits June 28, 2026 19:49
Covers common issues with uteke auto-recall in gateway mode:
- Memory provider not activating (gateway limitation)
- Hook loaded but irrelevant recall results
- Memory quality maintenance commands
- Hermes update safety
- Multi-agent shared gateway setup
- uteke list vs stats count discrepancy
- Add Mode C section to integrations/hermes.md with full setup guide
- handler.py code, config.yaml registration, comparison table
- Race safety explanation (subprocess stdout, no shared state)
- Update getting-started.md to reference all 3 Hermes modes
cmd = [str(UTEKE_BIN), "recall", "--namespace", AGENT,
"--limit", str(limit), "--json", query]
try:
proc = subprocess.run(cmd, capture_output=True, text=True, timeout=15)
if context.get("session_id", "").startswith("cron_"):
return

result = subprocess.run(
if context.get("session_id", "").startswith("cron_"):
return

result = subprocess.run(
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (3)

  • docs/integrations/hermes.md:306 — In the pre_llm_call shell hook example, recalled memory content is copied directly into the JSON response via lines.append(f"{i}. [{mem['score']:.2f}] {content}") and then emitted as {"context": ...}. Because content comes from stored memories and is not sanitized or delimited as untrusted data, any memory containing prompt-injection instructions will be injected verbatim into every future prompt. This creates a concrete prompt-injection vector in the documented integration pattern.
  • docs/integrations/hermes.md:428 — The gateway hook example writes memory text directly into a Markdown context file with lines.append(f"- ({item.get('score', 0):.3f}) {mem.get('content', '')}") and then CONTEXT_FILE.write_text("\n".join(lines)). Since mem.get('content', '') is untrusted recalled data, a stored memory can inject arbitrary instructions or malformed markdown into the file that the agent is later told to read, making prompt injection persistent across sessions.
  • docs/integrations/hermes.md:428 — The gateway workaround claims concurrent safety elsewhere, but this example writes all recalled context for an agent to a single path, CONTEXT_FILE = pathlib.Path(f"/tmp/hermes/uteke-context/{AGENT}.md"). Multiple simultaneous agent:start events for the same agent will overwrite the same file, so one session can read another session's recall results or see partially updated content.

Review powered by cora-cli · BYOK · MIT

@ajianaz

ajianaz commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator Author

Duplicate of #491 which is more accurate (no contradictory emit()/context-file pattern in troubleshooting). Merging #491 instead. The getting-started 3-mode callout from this PR will be ported in a follow-up.

@ajianaz ajianaz closed this Jun 29, 2026
KazamiHazaki pushed a commit to KazamiHazaki/uteke that referenced this pull request Jul 2, 2026
After merging codecoradev#491 (Mode C docs), the getting-started Hermes callout
still referenced only Mode B. Update to list all 3 modes with links
to the full integration docs.

Ported from codecoradev#490 (closed as duplicate).
@ajianaz
ajianaz deleted the docs/pre-llm-call-hook-mode branch July 9, 2026 14:27
ajianaz added a commit that referenced this pull request Aug 13, 2026
After merging #491 (Mode C docs), the getting-started Hermes callout
still referenced only Mode B. Update to list all 3 modes with links
to the full integration docs.

Ported from #490 (closed as duplicate).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants