feat(headless): integration of ag-ui client to generate head and follow up answers#7153
Open
feat(headless): integration of ag-ui client to generate head and follow up answers#7153
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR integrates the @ag-ui/client library (version 0.0.45) to handle answer generation for both head answers and follow-up answers using the KGAS (Knowledge Graph Answer Service). The implementation establishes a clean architectural pattern with explicit AG-UI agents, separating transport, streaming event handling, and lifecycle management.
Changes:
- Introduces
@ag-ui/clientdependency and creates a newagentsfolder structure for answer generation - Refactors the generate answer listener middleware to use an
AnswerRunnerinstead of dispatching Redux actions directly - Implements
FollowUpAgentand associated strategy for handling follow-up answer generation via the/follow-upendpoint
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds @ag-ui/client@0.0.45 and its dependencies |
| packages/headless/package.json | Declares @ag-ui/client dependency |
| packages/headless/src/features/configuration/configuration-selectors.ts | Adds selectors for accessToken, organizationId, and environment |
| packages/headless/src/features/configuration/configuration-selectors.test.ts | Tests for new configuration selectors |
| packages/headless/src/app/listener-middleware/generate-answer-listener-middleware.ts | Refactors to use AnswerRunner instead of dispatching generateHeadAnswer action |
| packages/headless/src/app/listener-middleware/generate-answer-listener-middleware.test.ts | Updates tests for refactored listener middleware |
| packages/headless/src/app/engine.ts | Updates middleware creation to pass NavigatorContext provider to listener |
| packages/headless/src/api/knowledge/answer-generation/agents/endpoint-url-builder.ts | Creates URL builder for answer generation endpoints |
| packages/headless/src/api/knowledge/answer-generation/agents/endpoint-url-builder.test.ts | Tests for endpoint URL builder |
| packages/headless/src/api/knowledge/answer-generation/agents/answer-agent/answer-agent.ts | Implements custom HttpAgent for head answer requests |
| packages/headless/src/api/knowledge/answer-generation/agents/answer-agent/head-answer-strategy.ts | Implements AgentSubscriber for handling head answer streaming events |
| packages/headless/src/api/knowledge/answer-generation/agents/answer-agent/head-answer-strategy.test.ts | Tests for head answer strategy |
| packages/headless/src/api/knowledge/answer-generation/agents/answer-agent/answer-agent-runner.ts | Implements lifecycle management for AnswerAgent |
| packages/headless/src/api/knowledge/answer-generation/agents/answer-agent/answer-agent-runner.test.ts | Tests for answer agent runner |
| packages/headless/src/api/knowledge/answer-generation/agents/follow-up-agent/follow-up-agent.ts | Implements custom HttpAgent for follow-up answer requests |
| packages/headless/src/api/knowledge/answer-generation/agents/follow-up-agent/follow-up-answer-strategy.ts | Implements AgentSubscriber for handling follow-up answer streaming events |
| packages/headless/src/api/knowledge/answer-generation/agents/follow-up-agent/follow-up-answer-strategy.test.ts | Tests for follow-up answer strategy |
| packages/headless/src/controllers/knowledge/generated-answer/headless-generated-answer-with-follow-ups.ts | Integrates FollowUpAgent for askFollowUp method |
| packages/headless/src/controllers/knowledge/generated-answer/headless-generated-answer-with-follow-ups.test.ts | Updates tests for follow-up integration |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
packages/headless/src/api/knowledge/answer-generation/agents/follow-up-agent/follow-up-answer-strategy.ts:17
- The
runIdvariable is declared but not initialized. If any event handler other thanonRunStartedEventis called first (e.g.,onTextMessageContentEvent,onCustomEvent,onRunErrorEvent, oronRunFinishedEvent), therunIdwill be undefined when dispatching actions. While the AG-UI client likely guarantees thatonRunStartedEventis always called first, this creates a potential runtime error. Consider initializingrunIdto a default value or adding defensive checks in the other handlers to ensurerunIdis defined before using it.
let runId: string;
...ages/headless/src/api/knowledge/answer-generation/agents/answer-agent/answer-agent-runner.ts
Show resolved
Hide resolved
packages/headless/src/api/knowledge/answer-generation/agents/endpoint-url-builder.test.ts
Outdated
Show resolved
Hide resolved
SimonMilord
reviewed
Feb 26, 2026
SimonMilord
approved these changes
Feb 26, 2026
Contributor
SimonMilord
left a comment
There was a problem hiding this comment.
very nice, flow makes sense
erocheleau
approved these changes
Feb 27, 2026
Collaborator
erocheleau
left a comment
There was a problem hiding this comment.
Little comment, but consider it approved after
...less/src/api/knowledge/answer-generation/agents/follow-up-agent/follow-up-answer-strategy.ts
Outdated
Show resolved
Hide resolved
...ages/headless/src/api/knowledge/answer-generation/agents/answer-agent/answer-agent-runner.ts
Show resolved
Hide resolved
...ages/headless/src/api/knowledge/answer-generation/agents/answer-agent/answer-agent-runner.ts
Show resolved
Hide resolved
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.
SFINT-6610
Summary
This PR introduce the @ag-ui/client library in Headless which is now used to interact with the KGAS to support generating head answers and follow up answer.
Answer generation is now structured around explicit AG-UI agents, with clear separation between:
The goal is to keep the integration simple, explicit, and maintainable while establishing a clean architectural foundation for future enhancements.
Structure
A new
agentsfolder has been introduced under:src/api/answer-generation/It contains two submodules:
answer-agentfollow-up-agentEach submodule encapsulates everything required for its respective agent.
Head Answer Flow
The
answer-agentmodule is organized into three clear responsibilities:1. Agent
AnswerAgent/answerendpoint2. Strategy
3. Runner
Integration
The
AnswerRunneris used inside the generated answer listener middleware:Follow-Up Flow
The
follow-up-agentmodule contains:1. FollowUpAgent
/follow-upendpoint2. FollowUpStrategy
Integration
The follow-up agent is used by the
GeneratedAnswerWithFollowUpscontroller.When
askFollowUpis called:FollowUpAgentruns against the/follow-upendpoint.