Tags: llm4s/llm4s
Tags
Fix tool calling bug causing 400 errors with Anthropic API (#282) * Fix tool calling bug causing 400 errors with Anthropic API This fixes a critical bug where AssistantMessages with empty content were sent to Anthropic after tool execution, causing 400 errors. Changes: - AnthropicClient: Skip AssistantMessages with tool calls when building params (Anthropic infers them from tool results). Send ToolMessages as prefixed user messages instead of plain text. - Message validation: Allow multiple consecutive ToolMessages from the same batch of tool calls. Validation now finds the most recent AssistantMessage with tool calls and verifies ToolMessage IDs match. - Added comprehensive multi-provider test suite that verifies both OpenAI and Anthropic handle tool calling equivalently through the complete flow: User → LLM → Tool → LLM (processes results) → Response - Upgraded Anthropic SDK from 2.2.0 to 2.8.1 All tests passing (44/44 agent and message tests + 4/4 new multi-provider tests). Fixes: Tool calling flow where empty AssistantMessage content caused Anthropic API 400 errors after tool execution. * Fix tracing tests to skip when Langfuse is configured The tracing tests expected default values (Console mode, no API keys), but were failing when Langfuse was configured via environment variables (LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, TRACING_MODE). Since environment variables cannot be easily cleared from within the JVM, these tests now detect if Langfuse is configured and skip gracefully using ScalaTest's cancel() mechanism. Changes: - EnhancedTracingSettingsSpec: Skip test if Langfuse is configured - TracingConfigSpec: Skip "defaults" test if Langfuse is configured Both tests now properly cancel when Langfuse environment variables are present, allowing the test suite to pass while still validating behavior when Langfuse is not configured.
Fix tool call failures and improve error messages (#249) Improved error messaging system: - Created structured ToolParameterError types for clear parameter validation errors - Improved SafeParameterExtractor for better error reporting with context - Consistent error format: 'Tool call [name] [specific issue]' - Clear distinction between missing, null, and wrong type errors - Shows available parameters when one is missing Changes: - Agent.scala: Fixed ToolMessage constructor argument order (line 159) - Created ToolParameterError.scala with structured error types - Created EnhancedParameterExtractor.scala for enhanced validation - Updated SafeParameterExtractor with improved error messages - Modified ToolFunction to handle null arguments properly - Updated ToolRegistry and MCPToolRegistry for new error types - Added comprehensive test coverage in AgentToolFailureTest.scala - Fixed test expectations in ParameterValidationTest and EnhancedErrorMessagesTest
docs: Add release documentation and clarify tag format requirements - Created RELEASE.md with detailed release process instructions - Updated README.md to clarify v-prefix requirement for version tags - Documented troubleshooting steps for release workflow issues - Standardized on v-prefixed tags (v0.1.11) for consistency
feat: Add native SDK streaming support for OpenAI and Anthropic (#199) - Fix compilation errors for new error hierarchy - Update sample files to use new error imports from org.llm4s.error package - Remove references to UnknownError which doesn't exist in new hierarchy - Fix wildcard imports for Scala 2/3 compatibility (* vs _) - Update ApiKey and ModelName creation methods to use apply() instead of create() - Fix AsyncResult import path - Update error field access (httpStatus instead of statusCode) - Implement streamComplete method in OpenAI, Anthropic, and OpenRouter clients - Add SSEParser for Server-Sent Events parsing (OpenRouter) - Create StreamingAccumulator for collecting streaming chunks - Add comprehensive streaming examples and tests - Support real-time token-by-token response streaming - Handle tool calls in streaming responses - Track token usage during streaming - Fix warnings and apply formatting - Remove unused imports in AnthropicClient - Fix unused pattern variables - Handle null case explicitly to avoid unreachable case warning - Apply scalafmt formatting Co-authored-by: Rory Graves <rory.graves@thetradedesk.com>
refactor: Refactor Agent.run to support running from existing state - Split run method into two: one that takes an AgentState, one that takes a query - The primary run method now accepts an initialState parameter - The query-based run method initializes state and delegates to the primary method - Added optional systemPromptAddition parameter to initialize method - Updated all callers to use the new method signatures This enables: - Resuming agent execution from saved states - Custom system prompt additions for domain-specific behavior - Better testability by running from specific states
fix: Use v-prefixed tags but strip v from artifact versions - Revert to using v-prefixed tags (e.g., v0.1.7) as per Git conventions - Strip the 'v' prefix when generating artifact versions for Maven Central - Ensures downstream users get clean version numbers (0.1.7) without 'v' - Fixes issue where release builds were creating snapshot versions
PreviousNext