strix
strix copied to clipboard
test: add unit tests for llm/utils module
Following up on @0xallam's comment on #157:
"I think we need to add even more unit tests now, especially to the most critical parts of the agent."
This PR adds tests for llm/utils.py - the core LLM response parsing logic.
Addresses #158
What's included
| Test Class | Coverage | Tests |
|---|---|---|
TestParseToolInvocations |
XML tool invocation parsing | 8 |
TestFixStopword |
Incomplete function tag handling | 4 |
TestFormatToolCall |
Tool call XML formatting | 4 |
TestCleanContent |
Content cleaning and XML removal | 6 |
TestTruncateToFirstFunction |
First function truncation | 4 |
Total: 26 tests, all passing.
Test plan
- [x] All 26 tests pass locally
- [x] Follows existing test patterns from
test_argument_parser.py - [x] Covers edge cases (empty content, HTML entities, multiline values, etc.)
Next steps (if this direction looks good)
I'm planning to continue adding tests for other critical modules:
| Module | Why it's critical |
|---|---|
agents/state.py |
Agent execution state management |
llm/memory_compressor.py |
Context window optimization |
tools/executor.py |
Tool execution logic |
Happy to adjust priorities based on your feedback!