-
Notifications
You must be signed in to change notification settings - Fork 879
Feat: General agents + presentations #252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: nightly
Are you sure you want to change the base?
Conversation
…ic coding agent implemented - Abstracted behaviors and objectives - Behavior and Objectives are bot h AgentComponent - CodeGeneratorAgent (Agent DO) houses common business logic - Implemented agentic coding agent and and assistant
- Implemented AI-powered project type prediction (app/workflow/presentation) with confidence scoring and auto-detection when projectType is 'auto' - Enhanced template selection to filter by project type and skip AI selection for single-template scenarios in workflow/presentation types - Added GitHub token caching in CodeGeneratorAgent for persistent OAuth sessions across exports - Updated commitlint config to allow longer commit messages (
- Initialize template cache during agent setup to avoid redundant fetches - Remove redundant project name prompt from template selection - Clean up default projectType fallback logic
- Added concurrency control to prevent duplicate workflow runs on the same PR - Replaced Claude-based comment cleanup with direct GitHub API deletion for better reliability - Enhanced code debugger instructions to handle Vite dev server restarts and config file restrictions
- Replaced unsafe type assertions with proper type guards for legacy state detection - Added explicit type definitions for deprecated state fields and legacy file formats - Eliminated all 'any' types while maintaining backward compatibility with legacy states
…ess design - Sandbox layer does not rely on templates now, instead expects raw files list - Tools to init/list templates, files - Templates can be chosen by agentic mode after creation - Restructured system prompt with detailed architecture explanations covering virtual filesystem, sandbox environment, and deployment flow - Better tool descriptions - Improved communication guidelines and workflow steps for better agent reasoning and execution
- Replaced agent mode toggle with project mode selector (App/Slides/Chat) that determines behavior type - Implemented agentic behavior detection for static content (docs, markdown) with automatic editor view - Conditionally render PhaseTimeline and deployment controls based on behavior type (phasic vs agentic)
- Replaced manual template_manager tool with init_suitable_template that uses the original template selector ai - Updated system prompts to emphasize template-first workflow for interactive projects with AI selector as mandatory first step - Simplified template selection process by removing manual list/select commands in favor of intelligent matching ```
- Added conversation history support to AgenticProjectBuilder with message preparation and context tracking - Implemented tool call completion callbacks to sync messages and trigger periodic compactification - Modified AgenticCodingBehavior to queue user inputs during builds and inject them between tool call chains using abort mechanism
- Fix importTemplate to actually work - Fixed template filtering logic to respect 'general' project type - Added behaviorType to logger context for better debugging - fixed not saving behaviorType to state
…ructor - Moved behaviorType and projectType initialization from hardcoded values to constructor-based setup - Changed initial state values to 'unknown' to ensure proper initialization through behavior constructor - Cleared template details cache when importing new templates to prevent stale data
- Moved user input idle check from PhasicCodingBehavior to CodeGeneratorAgent for consistent behavior across all modes - Fixed message order in agenticProjectBuilder to place history after user message instead of before - Added replaceExisting parameter to addConversationMessage for better control over message updates - Enhanced initial state restoration to include queued user messages and behaviorType - Added status and queuePosition fields
- Single convo id needs to be broadcasted but messages need to be saved with unique ids. - Fix message deduplication to use composite key (conversationId + role + tool_call_id) - Improved tool message filtering to validate against parent assistant tool_calls - Removed unused CodingAgentInterface stub file - Simplified addConversationMessage interface by removing replaceExisting parameter
- Added CompletionDetector interface and CompletionConfig for detecting task completion signals - Implemented dependency-aware parallel tool execution engine with resource conflict detection - Added LoopDetector to prevent infinite tool call loops with contextual warnings - Enhanced ToolCallContext with completion signal tracking and warning injection state - Modified tool execution to respect dependencies and execute in parallel groups
… and debugger - Added CompletionDetector to track completion signals via dedicated tools (mark_generation_complete, mark_debugging_complete) - Implemented LoopDetector to prevent infinite tool call loops with contextual warnings - Created wrapToolsWithLoopDetection utility to inject loop detection into tool execution flow - Enhanced system prompts to emphasize efficient parallel tool usage and completion discipline
Feat: Better tooling system
…at/general-agents
…ic coding agent implemented - Abstracted behaviors and objectives - Behavior and Objectives are bot h AgentComponent - CodeGeneratorAgent (Agent DO) houses common business logic - Implemented agentic coding agent and and assistant
- Implemented AI-powered project type prediction (app/workflow/presentation) with confidence scoring and auto-detection when projectType is 'auto' - Enhanced template selection to filter by project type and skip AI selection for single-template scenarios in workflow/presentation types - Added GitHub token caching in CodeGeneratorAgent for persistent OAuth sessions across exports - Updated commitlint config to allow longer commit messages (
- Initialize template cache during agent setup to avoid redundant fetches - Remove redundant project name prompt from template selection - Clean up default projectType fallback logic
…nge-builds into feat/general-agents
Feat: General agent creation, support for app, workflow and slides/docs creation
…at/refactor-agents-base
…at/refactor-agents-base
…at/refactor-agents-base
…nge-builds into feat/refactor-agents-base
b0e7319 to
f6f4207
Compare
…at/refactor-agents-base
- Remove duplicate "Blueprint generation complete" message from chat hook - Fix file saving logic to track saved files during generation callbacks - Ensure deployment to sandbox after template setup completion - Import FileState type for proper file tracking
|
Claude finished @AshishKumar4's task —— View job Code Quality & Security ReviewRecommendation: REQUEST CHANGES (Critical bug found) Executive SummaryThis is a significant architectural refactoring that successfully decouples agent behavior from Durable Objects infrastructure. The overall design is solid, but there is one critical bug in state migration that must be fixed before merging, plus several code quality improvements needed per CLAUDE.md standards. Critical Issues1. CRITICAL: State Migration Bug - Data Loss RiskLocation: The migration code computes
Impact: Affects all existing production sessions during deployment. Code Quality Issues (CLAUDE.md Violations)2. Type Safety: 'any' Type UsageLocation: const getTimestamp = (msg: any) => {The parameter is already typed as Other instances found:
Architecture ReviewPositive ChangesWell-Designed Abstractions:
Code Organization:
Migration Strategy:
Areas of Concern1. Type Assertions in Phasic Behavior const context = GenerationContext.from(this.state, this.getTemplateDetails(), this.logger);
if (!GenerationContext.isPhasic(context)) {
throw new Error('Expected PhasicGenerationContext');
}This is the correct approach and addresses previous review comments about unsafe type assertions. 2. Missing Import - Agentic Behavior
import { PhasicCodingBehavior } from './behaviors/phasic';
import { AgenticCodingBehavior } from './behaviors/agentic';This issue is RESOLVED - imports are present and correct. 3. State Machine Complexity Security AnalysisReviewed critical paths: Findings:
Note: This PR primarily refactors internal architecture without touching security-sensitive authentication, database queries, or API endpoints. The main security concern is the state migration bug which could cause availability issues. Breaking Changes ReviewBreaking Change: The PR description acknowledges this. The migration logic exists but is buggy (see Critical Issue #1). Once fixed, the migration should handle backward compatibility correctly. Missing from Migration:
Testing RecommendationsGiven the scope of this refactor, recommend:
SummaryMust Fix Before Merge:
Should Fix (CLAUDE.md compliance): Optional Improvements: Overall Assessment: |
| let migratedBehaviorType = state.behaviorType; | ||
| if (isStateWithAgentMode(state)) { | ||
| migratedBehaviorType = state.agentMode === 'smart' ? 'agentic' : 'phasic'; | ||
| needsMigration = true; | ||
| logger.info('Migrating agentMode to behaviorType', { | ||
| oldMode: state.agentMode, | ||
| newType: migratedBehaviorType | ||
| }); | ||
| } | ||
|
|
||
| return newState; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CRITICAL: State Migration Bug - behaviorType Not Applied
The migration logic computes migratedBehaviorType (lines 236-244) but NEVER assigns it to the newState object. This means:
- The migration is logged but not actually applied
- Existing sessions with
agentModewill lose their behavior preference - They will default to whatever
state.behaviorTypewas (likely undefined/unknown)
Fix Required:
| let migratedBehaviorType = state.behaviorType; | |
| if (isStateWithAgentMode(state)) { | |
| migratedBehaviorType = state.agentMode === 'smart' ? 'agentic' : 'phasic'; | |
| needsMigration = true; | |
| logger.info('Migrating agentMode to behaviorType', { | |
| oldMode: state.agentMode, | |
| newType: migratedBehaviorType | |
| }); | |
| } | |
| return newState; | |
| let migratedBehaviorType = state.behaviorType; | |
| if (isStateWithAgentMode(state)) { | |
| migratedBehaviorType = state.agentMode === 'smart' ? 'agentic' : 'phasic'; | |
| needsMigration = true; | |
| logger.info('Migrating agentMode to behaviorType', { | |
| oldMode: state.agentMode, | |
| newType: migratedBehaviorType | |
| }); | |
| // Apply the migrated value | |
| newState.behaviorType = migratedBehaviorType; | |
| delete stateWithDeprecated.agentMode; | |
| } | |
| return newState; |
This is a data integrity issue that could break existing user sessions.
| const isAgenticBlueprint = (bp?: Blueprint): bp is AgenticBlueprint => { | ||
| if (!bp) return false; | ||
| return 'plan' in bp && Array.isArray(bp.plan); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Low Priority: Inline Type Guard Can Be Simplified
While this is functional, the type guard doesn't need to be this verbose. TypeScript can infer from the property check alone:
| const isAgenticBlueprint = (bp?: Blueprint): bp is AgenticBlueprint => { | |
| if (!bp) return false; | |
| return 'plan' in bp && Array.isArray(bp.plan); | |
| }; | |
| const isAgenticBlueprint = (bp?: Blueprint): bp is AgenticBlueprint => { | |
| return !!bp && 'plan' in bp && Array.isArray(bp.plan); | |
| }; |
Note: Previous review comment suggested avoiding (bp as any).plan which has been correctly fixed here. This is just a minor simplification suggestion.
Summary
This PR refactors the agent architecture to separate behavior logic from infrastructure, enabling support for multiple agent behaviors (phasic and agentic modes).
Changes
Core Architecture
simpleGeneratorAgent.ts→baseAgent.tswith extracted base behavior classAgentInfrastructure<TState>interface to decouple behavior from Durable ObjectsBaseAgentBehavior<TState>abstract class with common agent functionalityworker/agents/core/phasic/behavior.ts(852 lines) - phasic behavior implementationsmartGeneratorAgent.ts- thin wrapper implementingAgentInfrastructureState Management
state.ts- split state intoBaseProjectState,PhasicState,AgenticStatetypes.ts- addedBehaviorType, genericAgentInitArgs<TState>agentMode: 'deterministic' | 'smart'withbehaviorType: 'phasic' | 'agentic'Operations & Services
worker/agents/to useICodingAgentinterfaceScreenshotAnalysisOperation.ts- screenshot handling moved/removedICodingAgentinstead of concrete classPhaseImplementation.ts- simplified, moved logic to behaviorGenerationContext.ts- addedPhasicGenerationContextvariantInterface Changes
ICodingAgent.ts- formalized interface for all agent behaviorsMotivation
The previous architecture tightly coupled agent behavior to Durable Objects infrastructure, making it difficult to:
This refactoring enables:
AgentInfrastructurefor unit testsTesting
Manual Testing:
Areas Requiring Extra Attention:
agentMode→ newbehaviorType)Breaking Changes
State Schema:
agentMode: 'deterministic' | 'smart'behaviorType: 'phasic' | 'agentic'Impact: Existing Durable Object sessions may need migration logic or will default to phasic mode.
Related Issues
ScreenshotAnalysisOperationremovalThis PR description was automatically generated by Claude Code