feat(agent): implement event-driven sub-turn PoC with context cancell…#1585
Closed
lppp04808 wants to merge 12 commits intosipeed:refactor/agentfrom
Closed
feat(agent): implement event-driven sub-turn PoC with context cancell…#1585lppp04808 wants to merge 12 commits intosipeed:refactor/agentfrom
lppp04808 wants to merge 12 commits intosipeed:refactor/agentfrom
Conversation
* Add support for azure openai provider * Add checks for deployment model name * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Addressing @Copilot suggestion to remove the init() function which seemed redundant * Fix readme * Fix linting checks --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…tting feat(logger): Custom console formatter for JSON and multiline strings
fix(provider/azure): lint err
…ation (sipeed#1316) This introduces the initial Proof of Concept for hierarchical agent execution (Sub-turns) to enable multi-agent steering and interruptability as designed in Issue sipeed#1316. Key implementations: - Core Lifecycle: Added spawnSubTurn to manage nested turn executions with depth limits. - Ephemeral Sessions: Sub-turns now use isolated memory (newEphemeralSession) to prevent polluting the parent's history. - EventBus Integration: Implemented SubTurnSpawnEvent, SubTurnResultDeliveredEvent, and SubTurnEndEvent for full observability. - Context & Interrupts: Sub-turns inherit a cancelable context (context.WithCancel(ctx)) from the parent. When a parent finishes (ts.Finish()), all running children are automatically aborted to prevent goroutine leaks. - Concurrency & Robustness: - Added deferred panic recovery to guarantee the emission of SubTurnEndEvent(Err). - Implemented Orphan Result Routing (SubTurnOrphanResultEvent) to handle edge cases where a delayed child result arrives after the parent has finished, preventing history pollution. Ref: sipeed#1316
feat/sec add github's dependabot to scan the lib sec.
* feat(agent): steering * fix loop * fix lint * fix lint
…ionStore for ephemeral - Remove duplicated type definitions (ToolResult, Session, Message) → use official types: - tools.ToolResult (from pkg/tools/result.go) - session.SessionStore + providers.Message (from pkg/session/session_store.go) - Change turnState.session from *Session to session.SessionStore - Ephemeral session now uses a pure in-memory implementation (no persistence) - Prepare runTurn() for real integration: - Placeholder remains, but designed to accept AgentInstance - Ready to hook into runAgentLoop / runLLMIteration once steering/turnState lands - Rebased onto refactor/agent (steering merged), resolves type mismatches This makes the sub-turn PoC more compatible with the ongoing agent refactor (sipeed#1316).
Author
|
move to #1636 |
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.
📝 Description
This PR introduces the initial Proof of Concept (PoC) for hierarchical agent execution (Sub-turns). This is a foundational step to enable multi-agent steering and interruptability within the execution loop, as
proposed in Issue #1316.
By allowing agents to safely spawn, monitor, and cancel sub-agents (sub-turns) without polluting the main session history, we lay the groundwork for more complex, multi-layered reasoning and tool execution.
Key Changes
spawnSubTurnto manage nested turn executions safely, including a configurable depth limit (maxSubTurnDepth).newEphemeralSessionto ensure sub-turns use isolated memory. This prevents the parent's session history from being polluted by intermediate child reasoning.context.WithCancel(ctx)). If a parent turn finishes (ts.Finish()), all running children are automatically aborted, effectivelypreventing goroutine leaks.
SubTurnSpawnEvent,SubTurnResultDeliveredEvent,SubTurnEndEvent,SubTurnOrphanResultEvent) for full observability into the sub-turn lifecycle.Currently utilizing a
MockEventBusfor the PoC.SubTurnEndEvent(Err).SubTurnOrphanResultEventto avoid state corruption or history pollution.Notes for Reviewers
MockEventBus) and fixed-size channels for pending results.🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
📚 Technical Context (Skip for Docs)
🧪 Test Environment
📸 Evidence (Optional)
Click to view Logs/Screenshots
☑️ Checklist