fix: truncate large hook payloads before forwarding to NeMo Relay#35
fix: truncate large hook payloads before forwarding to NeMo Relay#35nanookclaw wants to merge 1 commit into
Conversation
The NeMo Relay Axum server applies a default ~2 MiB body limit on /hook/hermes. Large but valid LLM turns (multi-message conversations, verbose tool outputs) silently exceed this limit, producing HTTP 413 and missing Phoenix/ATIF telemetry spans. Add a _truncate_payload() step in _forward() that progressively shrinks oversized payloads while preserving correlation metadata (task_id, session_id, model, etc.) and hook event structure: Phase 1: truncate message content strings (proportional budget) Phase 2: truncate response/assistant_message content Phase 3: truncate tool args and result strings Phase 4: aggressive — replace all content with [truncated] marker Threshold is 1.5 MiB, safely under Axum's ~2 MiB limit. Small payloads pass through unchanged (identity return, zero overhead). Fixes NVIDIA#22 Signed-off-by: Nanook Claw <nanook@agentmail.to>
2d5aef5 to
b79b101
Compare
|
@nanookclaw would you file a GH issue on NeMo Relay repo please? We can handle the case in Relay directly. |
|
Filed NVIDIA/NeMo-Relay#255 with the Relay-side oversized hook payload handling context. |
|
The Relay-side follow-up requested above looks done now: NVIDIA/NeMo-Relay#261 closed NVIDIA/NeMo-Relay#255 and shipped in NeMo Relay 0.4.0. That release raises the default hook payload limit to 20 MiB, adds I prepared and locally validated a minimal two-file patch for that path (
Happy to send that minimal bump if maintainers prefer this route. |
Summary
The NeMo Relay Axum server applies a default ~2 MiB body limit on
/hooks/hermes. Large but valid LLM turns silently return HTTP 413, so the interaction completes but Phoenix/ATIF telemetry is missing for that turn.Root Cause
_forward()sends the full serialized hook payload without checking size. When a Hermes turn produces a large payload (multi-message conversations, verbose tool outputs, long reasoning chains), the AxumJson<Value>extractor rejects it beforehermes::adapt(...)runs.Change Made
File:
examples/personal-community-sentiment-triage/agents/hermes/plugins/nemo-relay/__init__.pyAdded a
_truncate_payload()step in_forward()that progressively shrinks oversized payloads while preserving correlation metadata (task_id,session_id,model, etc.) and hook event structure:response.raw_responseandassistant_messagecontentargsandresultstrings[truncated]marker, set_truncated: trueThreshold is 1.5 MiB, safely under Axum's ~2 MiB limit. Small payloads pass through unchanged (identity return, zero overhead).
This is the client-side complement to any future server-side
DefaultBodyLimitincrease in NeMo Relay itself.Testing
Fixes #22