mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
test(api_server): _run_agent result now carries session_id for #16938
This commit is contained in:
parent
7f735b4db2
commit
314361733f
2 changed files with 9 additions and 2 deletions
|
|
@ -2488,7 +2488,9 @@ class APIServerAdapter(BasePlatformAdapter):
|
|||
# Include the effective session ID in the result so callers
|
||||
# (e.g. X-Hermes-Session-Id header) can track compression-
|
||||
# triggered session rotations. (#16938)
|
||||
result["session_id"] = getattr(agent, "session_id", session_id)
|
||||
_eff_sid = getattr(agent, "session_id", session_id)
|
||||
if isinstance(_eff_sid, str) and _eff_sid:
|
||||
result["session_id"] = _eff_sid
|
||||
return result, usage
|
||||
|
||||
return await loop.run_in_executor(None, _run)
|
||||
|
|
|
|||
|
|
@ -395,7 +395,12 @@ class TestAgentExecution:
|
|||
session_id="session-123",
|
||||
)
|
||||
|
||||
assert result == {"final_response": "ok"}
|
||||
# _run_agent annotates result with the effective agent.session_id
|
||||
# when it's a real string, so the response-header writer can track
|
||||
# compression-triggered session rotations (#16938). The mock agent
|
||||
# here doesn't set an explicit session_id string so the guard skips
|
||||
# the annotation — header will fall back to the provided session_id.
|
||||
assert result["final_response"] == "ok"
|
||||
assert usage == {"input_tokens": 1, "output_tokens": 2, "total_tokens": 3}
|
||||
mock_agent.run_conversation.assert_called_once_with(
|
||||
user_message="hello",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue