fix(terminus-2): preserve terminal response ID - #2835
Conversation
|
/ok to test ae77831 |
|
/claude review |
|
SHIP — no reliability concerns. Verified the correctness-critical invariants in
Net effect is improved observability (native rollouts now carry terminal-attribution metrics) with the 'existing token ids take precedence' invariant intact. Tests assert real behavior and are not vacuous. Both PR revision checks passed. |
|
/claude review |
|
SHIP — LGTM, no reliability concerns. Reviewed the token-capture correctness path closely ( What I verified:
No async/httpx/ray issues, no public-API breaks, no config-default violations. |
Reuse the final model response ID on the agent response so token capture can attribute the verified terminal call without relying on transformed content. Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
4bb2b3f to
86d9bd9
Compare
|
/claude review |
|
SHIP — LGTM, no reliability concerns. Propagates the terminal chat-completion |
| raise ContextLengthExceededError( | ||
| f"Model {self._model_name} context length exceeded (detected fake response id='chtcmpl-123')" | ||
| ) | ||
| response_id = response_dict.get("id") |
There was a problem hiding this comment.
can we get the terminal response id from _handle_llm_interaction, since terminus 2 has summarization enabled by default which goes through the same _llm https://github.com/harbor-framework/harbor/blob/9dddd797b57ab8a0f9d6352a20fce73abbb29573/src/harbor/agents/terminus_2/terminus_2.py#L531
instead maybe
async def _handle_llm_interaction(self, *args, **kwargs) -> tuple[Any, ...]:
result = await super()._handle_llm_interaction(*args, **kwargs)
llm = getattr(self, "_llm", None)
if isinstance(llm, NemoGymLLM):
self.terminal_response_id = llm.last_response_id
...
Then app.py:412-413 reads getattr(agent, "terminal_response_id", None).
There was a problem hiding this comment.
actually not sure, since subagents and compaction
|
|
||
| return NeMoGymResponse( | ||
| id=f"resp_{uuid4().hex}", | ||
| id=terminal_response_id or f"resp_{uuid4().hex}", |
There was a problem hiding this comment.
terminus-2 is the first of 13 agents to stop minting resp_{uuid4().hex}. Nothing in-repo asserts a resp_ prefix for it, so no contract break, but if the pattern is right the others want it too and it might belong in a shared helper.
Summary
This is needed when Terminus 2 uses out-of-band token capture. Responses that already carry native token IDs continue to use the existing short-circuit and do not perform terminal attribution.
Test plan