Skip to content

test: add unit tests for run_agent.py (AIAgent)#67

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
0xbyt4:test/add-run-agent-unit-tests
Feb 27, 2026
Merged

test: add unit tests for run_agent.py (AIAgent)#67
teknium1 merged 1 commit intoNousResearch:mainfrom
0xbyt4:test/add-run-agent-unit-tests

Conversation

@0xbyt4
Copy link
Copy Markdown
Contributor

@0xbyt4 0xbyt4 commented Feb 26, 2026

Summary

  • Add 71 unit tests for run_agent.py (AIAgent class) covering 16 methods across 3 groups
  • Pure functions (26 tests): _has_content_after_think_block, _strip_think_blocks, _extract_reasoning, _clean_session_content, _get_messages_up_to_last_assistant, _mask_api_key_for_logs
  • State/structure methods (33 tests): __init__, interrupt mechanism, _hydrate_todo_store, _build_system_prompt, _invalidate_system_prompt, _build_api_kwargs, _build_assistant_message, _format_tools_for_system_message
  • Conversation loop pieces (12 tests): _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 ~3s
  • uv run pytest -v — full suite 243 passed, no regressions
71 tests covering pure functions, state/structure methods, and
conversation loop pieces. OpenAI client and tool loading are mocked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants