-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Chore
0 / 20 of 2 issues completed
Copy link
Description
Description
All six ProcessRequest implementations (blocking + streaming for chatcompletions, messages, and responses) follow the same high-level flow, but each reimplements it independently, making the code hard to follow and difficult to unit test.
Goals:
- Identify the common flow that
ProcessRequestfollows across all implementations, and ensure the code and comments clearly reflect it - Extract shared logic into helper methods on each interception type's base type (provider-specific refactor, not a generic abstraction)
- Fix bugs and inconsistencies discovered during the refactor
- Improve unit testability: extracting helpers onto the base types means each step of the flow (tool call classification, tool invocation, result appending, usage recording) can be tested in isolation, without requiring full HTTP round-trip setup
The responses implementation has already partially accomplished this by extracting the agentic loop and recording logic into methods on the base type. The same pattern should be applied to messages and chatcompletions.
Suggested order of work:
messages(Anthropic); most duplication, most complexitychatcompletions(OpenAI): follows the same pattern, should be mechanical after Anthropicresponses(OpenAI): review for consistency
Reactions are currently unavailable
Sub-issues
Metadata
Metadata
Assignees
Labels
No labels