This document is a testing strategy for implementing the TypeScript version “as you understand it”. The purpose is to "create a working core first and then understand the differences (provider/compaction/tool output cache) step by step."
- Test runner assumes
bun:test - Don't use real LLM API (because it's not stable in CI/local)
- The provider connector is based on “serializer unit tests” and “SDK calls are thin”
- Manual smoke is enabled explicitly with a flag like
INTEGRATION=1
Prepare MockModel that implements BaseChatModel and return ChatInvokeCompletion (messages: BaseMessage[]) for each scenario.
example:
- First time: messages=[{role:"assistant", content:null, tool_calls:[echo]}]\n2. Second time: messages=[{role:"assistant", content:"done"}]
- systemPrompt is entered only once for the first time
- When there is a tool call, tool is executed and ToolMessage is entered in the history.
- Quits if there are no tool calls
- ToolMessage(is_error=true) when unknown tool
- If JSON of tool arguments is corrupted, parse error ToolMessage will occur.
- “Additional call for summarization” is made when maxIterations is reached (verified with MockModel)
- FinalResponseEvent is always the last
- StepStart/ToolCall/ToolResult/StepComplete for each tool call is in order
- If there is reasoning, ReasoningEvent is issued
- At the end without tool call, only
finalis output instead oftext
- zod validate works (invalid input is rejected before tool execution)
- tool return serialize rule (string/json/parts)
- tool exceptions are converted to is_error ToolMessage
- Check the cases where
output_refis given to ToolMessage
- Old ToolMessages are trimmed when the total size limit is exceeded.
output_refremains in trimmed ToolMessage- Can be expanded from reference ID with
tool_output_cache
- Return usage from MockModel and compaction will be triggered in case it exceeds threshold
- messages is replaced with “retain + summary”
- In the case of
auto=false, compaction is not activated even if the threshold is exceeded.
- When assistant passes history with tool_calls to compaction, tool_calls are removed (API error avoidance logic)
Here, we have a policy of “not calling the SDK” and at least check the following.
- Common Message → Conversion to SDK format does not work
- ToolDefinition → SDK format can be generated
- SDK format tool call → can be returned to common ToolCall
Integration tests for actual SDK calls will be prepared separately as “manual smoke” when needed.