refactor(ai): rename agent response interfaces#1466
Merged
Conversation
Disambiguate the AI contracts from the framework's other Response interfaces so custom providers, middleware, and stream handlers use explicit type names.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1466 +/- ##
=======================================
Coverage 69.19% 69.19%
=======================================
Files 370 370
Lines 29338 29338
=======================================
Hits 20300 20300
Misses 8106 8106
Partials 932 932 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR renames the AI response contracts from the generic Response / StreamableResponse to the more explicit AgentResponse / StreamableAgentResponse, and updates the framework AI implementation plus generated mocks to use the new contract names consistently.
Changes:
- Renamed AI response contracts to
AgentResponseandStreamableAgentResponseand updated provider/conversation/middleware signatures accordingly. - Updated core AI implementations (text response + streamable response + middleware wrapper) to implement the renamed contracts.
- Regenerated AI-related mocks and updated AI/OpenAI/unit tests to use the new mock types and contract names.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
mocks/ai/StreamableResponse.go |
Removed old generated mock for deprecated StreamableResponse. |
mocks/ai/StreamableAgentResponse.go |
Added regenerated mock for StreamableAgentResponse. |
mocks/ai/Response.go |
Removed old generated mock for deprecated Response. |
mocks/ai/AgentResponse.go |
Added regenerated mock for AgentResponse. |
mocks/ai/Provider.go |
Updated provider mock to return AgentResponse / StreamableAgentResponse. |
mocks/ai/Next.go |
Updated Next mock to return AgentResponse. |
mocks/ai/Middleware.go |
Updated middleware mock to return AgentResponse. |
mocks/ai/Conversation.go |
Updated conversation mock to return AgentResponse / StreamableAgentResponse. |
contracts/ai/stream.go |
Removed the old StreamableResponse contract from the streaming contract file. |
contracts/ai/response.go |
Renamed Response → AgentResponse and introduced StreamableAgentResponse contract. |
contracts/ai/provider.go |
Updated provider interface to use renamed response contracts. |
contracts/ai/middleware.go |
Updated middleware Next and Handle signatures to use AgentResponse. |
contracts/ai/image.go |
Moved ImageStorer contract here (still within contracts/ai). |
contracts/ai/ai.go |
Updated conversation interface to use renamed response contracts. |
ai/streamable_response.go |
Updated stream implementation to implement StreamableAgentResponse and use AgentResponse in callbacks/runner. |
ai/streamable_response_test.go |
Updated stream tests to use AgentResponse / StreamableAgentResponse types. |
ai/response.go |
Updated NewTextResponse and Then to use AgentResponse. |
ai/provider_test.go |
Updated provider test stub signatures to the renamed contracts. |
ai/option_test.go |
Updated option middleware test stubs to return AgentResponse. |
ai/openai/provider.go |
Updated OpenAI provider to return renamed response contracts (prompt + streaming). |
ai/openai/provider_test.go |
Updated OpenAI stream test callback type to AgentResponse. |
ai/middleware_response.go |
Updated middleware response wrapper to implement AgentResponse. |
ai/conversation.go |
Updated conversation prompt/stream and middleware pipeline to use renamed response contracts. |
ai/conversation_test.go |
Updated conversation tests/stubs/mocks to AgentResponse / StreamableAgentResponse. |
ai/application_test.go |
Updated application tests and stubs to use AgentResponse / StreamableAgentResponse. |
LinboLen
added a commit
to LinboLen/framework
that referenced
this pull request
May 11, 2026
* origin/master: feat(ai): add audio generation support (goravel#1467) chore: Update non-major dependencies (goravel#1468) refactor(ai): rename agent response interfaces (goravel#1466) feat(ai): add image storage helpers (goravel#1465) chore: Update non-major dependencies (goravel#1464)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AgentResponseandStreamableAgentResponseso custom AI integrations no longer rely on ambiguous generic type names.Closes goravel/goravel#918
Why
The AI package exposed generic
ResponseandStreamableResponseinterfaces even though the framework already has several unrelatedResponsecontracts for HTTP, testing, and auth. Renaming the AI contracts makes custom providers and middleware easier to read and implement because the type names now describe the AI domain directly.This keeps the public AI API aligned across the framework, custom providers, and generated mocks, while removing the need to mentally disambiguate which
Responseinterface a provider or middleware hook is expected to return.