WHAT: Enhanced tool call handling in Responses API adapter with better validation, error handling, and test coverage
WHY: The adapter lacked robust tool call parsing and validation, leading to potential issues with malformed tool calls and incomplete test coverage. We needed to improve error handling and add comprehensive tests for real tool call scenarios.
HOW: Enhanced tool call result parsing with defensive null checking; improved assistant tool call parsing with proper validation; enhanced response tool call parsing with better structure and support for multiple tool call types; added validation for streaming tool call handling; updated tests to validate real tool call parsing from API; added multi-turn conversation test with tool result injection
Testing: All 3 integration tests pass with real API calls. Validated tool call parsing and tool result conversion working correctly. Real tool call detected and parsed successfully.
WHAT: Refactored queryOpenAI to prepare adapter context outside withRetry and execute API calls inside withRetry
WHY: The previous implementation mixed adapter preparation and execution, causing type confusion and state management issues
HOW: Created AdapterExecutionContext and QueryResult types, moved adapter context creation before withRetry block, wrapped all API calls (Responses API, Chat Completions, and legacy) inside withRetry with unified return structure, added normalizeUsage() helper to handle token field variations, ensured responseId and content are properly preserved through the unified return path
Problem: Mixed return types from withRetry callback caused content loss when
adapter returned AssistantMessage but outer code expected ChatCompletion.
Solution: Restructured queryOpenAI to separate adapter and legacy paths:
- Adapter path (responsesAPI): Direct execution, early return, no withRetry
- Legacy path (chat_completions): Uses withRetry for retry logic
Benefits:
✅ No type confusion - adapter path never enters withRetry
✅ Clean separation of concerns - adapters handle format, legacy handles retry
✅ Streaming-ready architecture for future async generator implementation
✅ Content displays correctly in CLI (fixed empty content bug)
✅ All 14 tests pass (52 assertions)
Additional changes:
- Added StreamingEvent type to base adapter for future async generators
- Updated UnifiedResponse to support both string and array content
- Added comments explaining architectural decisions and future improvements
- Fixed content loss bug in responses API path
Prevents adapter responses from being overwritten with empty content.
Adds early return check when response.type === 'assistant' to preserve
correctly formatted content from the adapter path.
All tests pass, CLI content now displays correctly.
WHAT:
- Refactored ResponsesAPIAdapter to support async generator streaming pattern
- Added parseStreamingResponse() method that yields StreamingEvent incrementally
- Maintained backward compatibility with parseStreamingResponseBuffered() method
- Updated UnifiedResponse type to support both string and array content formats
WHY:
- Aligns Responses API adapter with Kode's three-level streaming architecture (Provider → Query → REPL)
- Enables real-time UI updates with text appearing progressively instead of all at once
- Supports TTFT (Time-To-First-Token) tracking for performance monitoring
- Matches Chat Completions streaming implementation pattern for consistency
- Resolves architectural mismatch between adapter pattern and streaming requirements
HOW:
- responsesAPI.ts: Implemented async *parseStreamingResponse() yielding events (message_start, text_delta, tool_request, usage, message_stop)
- base.ts: Added StreamingEvent type definition and optional parseStreamingResponse() to base class
- modelCapabilities.ts: Updated UnifiedResponse.content to accept string | Array<{type, text?, [key]: any}>
- parseResponse() maintains backward compatibility by calling buffered version
- All 14 tests pass with no regressions
WHAT: Fix critical CLI crash with content.filter() error and implement OpenAI Responses API integration with comprehensive testing
WHY: CLI was crashing with 'TypeError: undefined is not an object (evaluating "content.filter")' when using OpenAI models, preventing users from making API calls. Additionally needed proper Responses API support with reasoning tokens.
HOW:
• Fix content extraction from OpenAI response structure in legacy path
• Add JSON/Zod schema detection in responsesAPI adapter
• Create comprehensive test suite for both integration and production scenarios
• Document the new adapter architecture and usage
CRITICAL FIXES:
• claude.ts: Extract content from response.choices[0].message.content instead of undefined response.content
• responsesAPI.ts: Detect if schema is already JSON (has 'type' property) vs Zod schema before conversion
FILES:
• src/services/claude.ts - Critical bug fix for OpenAI response content extraction
• src/services/adapters/responsesAPI.ts - Robust schema detection for tool parameters
• src/test/integration-cli-flow.test.ts - Integration tests for full flow
• src/test/chat-completions-e2e.test.ts - End-to-end Chat Completions compatibility tests
• src/test/production-api-tests.test.ts - Production API tests with environment configuration
• docs/develop/modules/openai-adapters.md - New adapter system documentation
• docs/develop/README.md - Updated development documentation
WHAT: Add support for OpenAI Responses API in Kode CLI adapter
WHY: Enable GPT-5 and similar models that require Responses API instead of Chat Completions; fix HTTP 400 errors and schema conversion failures
HOW: Fixed tool format to use flat structure matching API spec; added missing critical parameters (include array, parallel_tool_calls, store, tool_choice); implemented robust schema conversion handling both Zod and pre-built JSON schemas; added array-based content parsing for Anthropic compatibility; created comprehensive integration tests exercising the full claude.ts flow
AFFECTED FILES:
- src/services/adapters/responsesAPI.ts: Complete adapter implementation
- src/services/openai.ts: Simplified request handling
- src/test/integration-cli-flow.test.ts: New integration test suite
- src/test/responses-api-e2e.test.ts: Enhanced with production test capability
VERIFICATION:
- Integration tests pass: bun test src/test/integration-cli-flow.test.ts
- Production tests: PRODUCTION_TEST_MODE=true bun test src/test/responses-api-e2e.test.ts
WHAT: Implement Responses API adapter with full SSE streaming support to enable Kode CLI working with GPT-5 and other models that require OpenAI Responses API format
WHY: GPT-5 and newer models use OpenAI Responses API (different from Chat Completions) which returns streaming SSE responses. Kode CLI needed a conversion layer to translate between Anthropic API format and OpenAI Responses API format for seamless model integration
HOW: Created ResponsesAPIAdapter that converts Anthropic UnifiedRequestParams to Responses API format (instructions, input array, max_output_tokens, stream=true), added SSE parser to collect streaming chunks and convert back to UnifiedResponse format. Fixed ModelAdapterFactory to properly select Responses API for GPT-5 models. Updated parseResponse to async across all adapters. Added production tests validating end-to-end conversion with actual API calls
Added update log section announcing Windows support via Git Bash, Unix subsystems,
or WSL (Windows Subsystem for Linux) for all Windows users.
- Added Update Log section to English README
- Added 更新日志 section to Chinese README
- Dated announcement as 2025-08-29
This is a major license change to better encourage open source contributions
and accelerate the global advancement of AI agent development.
Changes:
- Replace AGPLv3 LICENSE file with Apache 2.0 license text
- Update package.json license field from ISC to Apache-2.0
- Add prominent announcement in both README files about the license change
- Update license badges in README files
The Apache 2.0 license allows free use in both open source and commercial projects
with only attribution requirements, removing barriers to innovation and collaboration.
- Add WebSearchTool with DuckDuckGo integration for web search
- Provides titles, snippets, and links for current information
- Add URLFetcherTool for AI-powered web content analysis
- Fetches and converts HTML content to markdown
- Processes content using AI with user-provided prompts
- Includes 15-minute caching for efficiency
- Uses queryQuick for fast content analysis
- Register both tools in the tools registry
- Update documentation to reflect new web capabilities
- Added a new function to split PATH entries correctly for both Windows and POSIX environments.
- Improved shell detection logic to utilize the new PATH splitting function, ensuring accurate path handling across different platforms.