v1.4.1
Bug Fix: JSON Object Encoding for Tool Inputs
Fixes an issue where PHP's json_decode($json, true) converts empty JSON objects {} to empty arrays [], which then re-encode as [] instead of {}. This caused the Anthropic API to reject tool_use requests with "Input should be a valid dictionary".
Changes
- New
ToolExecutionTrait— shared trait withnormalizeContentBlocks(),executeTools(), andextractTextContent()methods, eliminating code duplication across all loop implementations - ReactLoop, ReflectionLoop, PlanExecuteLoop, StreamingLoop — all now use the trait and normalize
tool_use.inputtostdClassbefore adding to message history - Tool::toDefinition() — casts
propertiesto(object)for correct API serialization - Unit tests — added tests for empty and non-empty input normalization
- .gitignore — added runtime storage directories