Conversation
NoOne7135
commented
Jun 9, 2026
Contributor
- Added AgentRuntimeFactory to encapsulate AgentRuntime creation logic.
- Refactored simpleAgent.ts to streamline agent execution and remove deprecated code.
- Implemented SpeechTurnService for handling speech input and response processing.
- Created AgentToolProvider for managing API-based tools.
- Introduced TurnLifecycleService and TurnPersistenceService for managing turn state and persistence.
- Added TurnPromptBuilder for constructing prompts based on user input and context.
- Implemented TurnStreamConsumer and VegaLiteStreamBuffer for processing streaming responses.
- Updated turnTypes.ts to define new types for agent turn handling.
- Refactored AgentTurnService to utilize new services and improve code organization.
- Added AgentRuntimeFactory to encapsulate AgentRuntime creation logic. - Refactored simpleAgent.ts to streamline agent execution and remove deprecated code. - Implemented SpeechTurnService for handling speech input and response processing. - Created AgentToolProvider for managing API-based tools. - Introduced TurnLifecycleService and TurnPersistenceService for managing turn state and persistence. - Added TurnPromptBuilder for constructing prompts based on user input and context. - Implemented TurnStreamConsumer and VegaLiteStreamBuffer for processing streaming responses. - Updated turnTypes.ts to define new types for agent turn handling. - Refactored AgentTurnService to utilize new services and improve code organization.
There was a problem hiding this comment.
Pull request overview
This PR refactors agent “turn” execution into smaller services (lifecycle, context building, prompt building, runtime streaming, and stream consumption) and moves speech handling out of AgentTurnService, aiming to make turn handling more modular and maintainable.
Changes:
- Rewires plugin initialization to build a composed
AgentTurnServiceplus a dedicatedSpeechTurnService. - Introduces new turn/runtime abstractions (
AgentRuntime,Turn*services, stream consumer/buffer, new turn types). - Updates tool event wiring to use
context.emitand route tool-call observability through the API tools middleware.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| index.ts | Constructs the new runtime/tooling/turn services and wires handleSpeechTurn to SpeechTurnService. |
| agentTurnService.ts | Refactors turn preparation/execution/persistence around new services and removes inline speech handling. |
| agent/turn/VegaLiteStreamBuffer.ts | New buffering logic for vega-lite fenced blocks while streaming text deltas. |
| agent/turn/turnTypes.ts | New shared types for turn inputs, prepared turns, runtime inputs, and results. |
| agent/turn/TurnStreamConsumer.ts | New streaming consumer extracting reasoning/text deltas and using the vega-lite buffer. |
| agent/turn/TurnPromptBuilder.ts | New prompt builder (system prompt + language detection + user message). |
| agent/turn/TurnPersistenceService.ts | New persistence wrapper for touching sessions and updating turn responses/debug. |
| agent/turn/TurnLifecycleService.ts | New lifecycle wrapper for start/finish (create turn + persist response). |
| agent/turn/TurnContextBuilder.ts | New context builder with defaults for time zone and admin public origin. |
| agent/tools/navigateUser.ts | Renames context event emitter field from emitAgentEvent to emit. |
| agent/tools/AgentToolProvider.ts | New provider encapsulating API-based tool prep + tool list creation. |
| agent/speech/SpeechTurnService.ts | New speech turn handler (transcribe → run agent → synthesize/stream audio). |
| agent/simpleAgent.ts | Removes deprecated agent runner and exports middleware type + metrics logger used by runtime. |
| agent/runtime/AgentRuntime.ts | New runtime that creates the langchain agent, middleware chain, and streams messages. |
| agent/runtime/AgentContext.ts | New runtime context schema and adapter (toLangchainAgentContext). |
| agent/models/AgentModeResolver.ts | New resolver for selecting a mode by name (or default). |
| agent/models/AgentModelFactory.ts | New factory for creating primary/summary models and model middleware. |
| agent/middleware/apiBasedTools.ts | Emits tool-call events via context.emit and records them in sequenceDebugSink. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.