test: add unit tests for run_agent.py (AIAgent)#67
Merged
Conversation
71 tests covering pure functions, state/structure methods, and conversation loop pieces. OpenAI client and tool loading are mocked.
sudo-yf
pushed a commit
to sudo-yf/hermes-agent
that referenced
this pull request
Apr 5, 2026
…usResearch#67) The webui stores display-only fields on messages (attachments, timestamp, _ts) for UI rendering. These leaked into the conversation_history passed to AIAgent.run_conversation(). Most providers ignore unknown fields, but Z.AI/GLM tries to deserialize 'attachments' as its native ChatAttachments type, causing HTTP 400 on every subsequent message after an image upload. Fix: _sanitize_messages_for_api() creates a clean copy with only API-standard keys (role, content, tool_calls, tool_call_id, name, refusal) before passing to run_conversation(). Applied to both the streaming path (streaming.py) and non-streaming path (routes.py). Closes NousResearch#66 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
angelburgosrosado
pushed a commit
to angelburgosrosado/hermes-agent
that referenced
this pull request
Apr 27, 2026
…t-tests test: add unit tests for run_agent.py (AIAgent)
olympus-terminal
pushed a commit
to olympus-terminal/hermes-agent
that referenced
this pull request
May 16, 2026
…t-tests test: add unit tests for run_agent.py (AIAgent)
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
…t-tests test: add unit tests for run_agent.py (AIAgent)
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
run_agent.py(AIAgentclass) covering 16 methods across 3 groups_has_content_after_think_block,_strip_think_blocks,_extract_reasoning,_clean_session_content,_get_messages_up_to_last_assistant,_mask_api_key_for_logs__init__, interrupt mechanism,_hydrate_todo_store,_build_system_prompt,_invalidate_system_prompt,_build_api_kwargs,_build_assistant_message,_format_tools_for_system_message_execute_tool_calls,_handle_max_iterations,run_conversation(stop, tool calls, interrupt, invalid tool retry, empty content fallback, context compression)Test plan
uv run pytest tests/test_run_agent.py -v— 71 passed in ~3suv run pytest -v— full suite 243 passed, no regressions