Repository navigation
[ARCHITECTURE/DOC] Improve Task Execution Model and Documentation #204
Copy link
Copy link
Open
Labels
coreFundamental operations and essential features of AgenticJSFundamental operations and essential features of AgenticJSdocumentationImprovements or additions to documentationImprovements or additions to documentationdxDeveloper experienceDeveloper experiencefeedback discordmulti-agent-coordinationpriority-focus
Description
Context
Based on user feedback (from Saro), we've identified critical gaps in both our architecture and documentation regarding task execution and state management. The user attempted to implement pre/post processing hooks through a non-existent execute() function, highlighting several important issues:
-
Missing Extension Points
- Users are looking for clear ways to hook into task lifecycle
- No obvious way to add pre/post processing around task execution
- Lack of clear extension points for customizing agent behavior
-
Architecture Visibility
- The current task execution model (
workOnTask,agenticLoop) is not clearly exposed - State management through the store system isn't immediately obvious
- Task lifecycle events and hooks aren't discoverable
- The current task execution model (
-
Mental Model Mismatch
- Users expect familiar patterns (like React's hooks) for extending functionality
- The framework's actual architecture (store-based state management, task lifecycle) isn't intuitive
- Gap between user expectations and framework design
Impact
These issues are causing:
- Users to attempt implementing features in ways that won't work
- Confusion about how to properly extend the framework
- Missed opportunities to use built-in features
- Extra development effort trying to work around framework limitations
Proposed Solutions
- Architecture Enhancements
// Example of potential new extension points
class Agent extends BaseAgent {
// Clear lifecycle hooks
onTaskStart?: (task: Task) => Promise<void>;
onTaskComplete?: (task: Task, result: any) => Promise<void>;
// Pre/post processing hooks
beforeThinking?: (context: TaskContext) => Promise<void>;
afterThinking?: (context: TaskContext, result: any) => Promise<void>;
// Tool execution hooks
beforeToolExecution?: (tool: Tool, input: any) => Promise<void>;
afterToolExecution?: (tool: Tool, result: any) => Promise<void>;
}-
Documentation Improvements
- Add a "Task Lifecycle" guide explaining the execution flow
- Create an "Extension Points" section in docs
- Document the store-based state management system
- Provide examples of common customization patterns
-
Developer Experience
- Add TypeScript types for all extension points
- Create a debugging guide for task execution
- Add logging/tracing options for task lifecycle
- Provide example implementations of common patterns
Questions to Consider
- What are the most common extension points users need?
- How can we make the architecture more discoverable?
- What patterns from other frameworks should we support?
- How can we better communicate the framework's mental model?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
coreFundamental operations and essential features of AgenticJSFundamental operations and essential features of AgenticJSdocumentationImprovements or additions to documentationImprovements or additions to documentationdxDeveloper experienceDeveloper experiencefeedback discordmulti-agent-coordinationpriority-focus
Type
Projects
- StatusShow more project fieldsNo status
Activity