Skip to content

test(agent): unit tests for parseActionPlan, truncateString, and prepareHistoryParts#905

Merged
harshithmullapudi merged 3 commits into
RedPlanetHQ:mainfrom
omjeem:test/agent-pure-logic-unit-tests
Jun 17, 2026
Merged

test(agent): unit tests for parseActionPlan, truncateString, and prepareHistoryParts#905
harshithmullapudi merged 3 commits into
RedPlanetHQ:mainfrom
omjeem:test/agent-pure-logic-unit-tests

Conversation

@omjeem

@omjeem omjeem commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds 62 unit tests across 3 new test files to cover some previously untested pure-logic helpers in services/agent/:

File Function(s) Tests
decision.test.ts parseActionPlan, normalizeActionPlan, createFallbackPlan 30
truncate-result.test.ts truncateString, truncateToolResult 20
prepare-history-parts.test.ts prepareHistoryParts 12

These helpers are used in decision parsing, history preparation, and tool-result truncation. Since they're pure functions with no DB or network dependencies, the added tests remain fast and deterministic while helping improve confidence around existing behavior.

Coverage Highlights

  • parseActionPlan: covers direct JSON parsing, code-fenced JSON parsing, regex fallback behavior, validation boundaries, and malformed input handling.
  • truncateString: covers truncation behavior, head/tail split ratio, inline marker formatting, byte-count display (B/KB/MB), default limits, and metadata passthrough.
  • prepareHistoryParts: covers role-based passthrough, tool-call preservation, tool-agent-* output collapsing, and edge cases around missing or non-string outputs.

Testing

npx vitest run apps/webapp/app/services/agent/__tests__
# 5 files, 89 tests (62 new + 27 existing), 0 failures
Screenshot 2026-06-15 at 9 02 25 PM Screenshot 2026-06-15 at 9 02 57 PM Screenshot 2026-06-15 at 9 03 19 PM

@harshithmullapudi harshithmullapudi merged commit 8c98a66 into RedPlanetHQ:main Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants