Skip to content

Commit 72bbbb9

Browse files
committed
feat(agents): add layer4 code-assistant-agent template
Add a new Layer 4 agent template (code-assistant-agent.yaml) that implements a complete coding assistant. The template provides autonomous task routing: it analyzes user requests, routes to Layer 3 workflows, coordinates multi-step tasks, and exposes a unified interface for capabilities such as bug investigation and fixing, code review, deep code investigation, and general Q&A. The file defines the agent's metadata, tags, inputs (e.g., task_description, workspace, llm_profile), and demonstrates the full agent architecture (Layer 4 → Layer 3 → Layer 2 → Layer 1 → Layer 0). This adds a reusable template for developers to instantiate a high-level code assistant without changing existing components.
1 parent 3154cb9 commit 72bbbb9

1 file changed

Lines changed: 294 additions & 0 deletions

File tree

Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
name: code-assistant-agent
2+
description: |
3+
Complete coding assistant agent with autonomous task routing.
4+
5+
Layer 4 agent that:
6+
- Analyzes user requests
7+
- Routes to appropriate Layer 3 workflows
8+
- Coordinates multi-step tasks
9+
- Provides unified interface to all agent capabilities
10+
11+
Supported tasks:
12+
- Bug investigation and fixing
13+
- Code review
14+
- Deep code investigation
15+
- General Q&A
16+
17+
This demonstrates the full agent architecture:
18+
Layer 4 (this) → Layer 3 (domain) → Layer 2 (patterns) → Layer 1 (primitives) → Layer 0 (blocks)
19+
tags:
20+
- agent
21+
- layer4
22+
- assistant
23+
- autonomous
24+
- complete
25+
inputs:
26+
task_description:
27+
type: str
28+
description: "Natural language description of task"
29+
required: true
30+
workspace:
31+
type: str
32+
description: "Project workspace directory"
33+
required: false
34+
default: "."
35+
llm_profile:
36+
type: str
37+
description: "LLM profile from ~/.workflows/llm-config.yml (e.g., 'quick', 'standard', 'deep')"
38+
required: false
39+
default: "standard"
40+
outputs:
41+
task_type:
42+
value: '{{blocks.classify_task.outputs.response_json.task_type}}'
43+
execution_result:
44+
value: '{{blocks.execute_task.succeeded ? "completed" : "failed"}}'
45+
summary:
46+
value: '{{blocks.final_summary.outputs.stdout}}'
47+
blocks:
48+
# Phase 1: Classify Task - Determine what the user wants (using quick profile for classification)
49+
- id: classify_task
50+
type: LLMCall
51+
inputs:
52+
profile: quick
53+
prompt: |
54+
Analyze the following user request and classify it into a task type.
55+
56+
User Request: {{inputs.task_description}}
57+
58+
Available task types:
59+
1. "bug_investigation" - User reports a bug and wants it investigated/fixed
60+
2. "code_review" - User wants code review for changes (git diff, PR, etc.)
61+
3. "investigation" - User wants to understand how something works in the codebase
62+
4. "feature_implementation" - User wants to implement a new feature (requires planning)
63+
5. "general" - General questions or tasks that don't fit above categories
64+
65+
Provide:
66+
- task_type: One of the above
67+
- confidence: How confident you are (0-1)
68+
- reasoning: Why you classified it this way
69+
- parameters: Extracted parameters for the task (if any)
70+
system_instructions: |
71+
You are a task classification expert for a coding assistant.
72+
Analyze user intent and route to appropriate workflows.
73+
Respond ONLY with valid JSON matching the schema - no markdown, no extra text.
74+
response_schema:
75+
type: object
76+
required: [task_type, confidence, reasoning, parameters]
77+
properties:
78+
task_type:
79+
type: string
80+
enum: [bug_investigation, code_review, investigation, feature_implementation, general]
81+
confidence:
82+
type: number
83+
minimum: 0
84+
maximum: 1
85+
reasoning:
86+
type: string
87+
parameters:
88+
type: object
89+
description: "Extracted parameters (e.g., file patterns, focus areas)"
90+
properties:
91+
focus_areas:
92+
type: string
93+
file_pattern:
94+
type: string
95+
bug_description:
96+
type: string
97+
investigation_topic:
98+
type: string
99+
max_retries: 3
100+
timeout: 30
101+
102+
# Phase 2: Execute Task - Route to appropriate workflow
103+
104+
# Route 2a: Bug Investigation
105+
- id: execute_bug_investigation
106+
type: Workflow
107+
inputs:
108+
workflow: bug-investigation-and-fix
109+
inputs:
110+
bug_description: '{{blocks.classify_task.outputs.response_json.parameters.bug_description ?? inputs.task_description}}'
111+
file_pattern: '{{blocks.classify_task.outputs.response_json.parameters.file_pattern ?? "*.py"}}'
112+
workspace: '{{inputs.workspace}}'
113+
llm_profile: '{{inputs.llm_profile}}'
114+
auto_fix: false
115+
condition: '{{blocks.classify_task.outputs.response_json.task_type}} == "bug_investigation"'
116+
depends_on: [classify_task]
117+
118+
# Route 2b: Code Review
119+
- id: execute_code_review
120+
type: Workflow
121+
inputs:
122+
workflow: code-review-assistant
123+
inputs:
124+
diff_source: git
125+
git_base_branch: main
126+
focus_areas: '{{blocks.classify_task.outputs.response_json.parameters.focus_areas ?? "general code quality, potential bugs, and best practices"}}'
127+
workspace: '{{inputs.workspace}}'
128+
llm_profile: '{{inputs.llm_profile}}'
129+
run_validation: true
130+
condition: '{{blocks.classify_task.outputs.response_json.task_type}} == "code_review"'
131+
depends_on: [classify_task]
132+
133+
# Route 2c: Deep Investigation
134+
- id: execute_investigation
135+
type: Workflow
136+
inputs:
137+
workflow: investigate-deeply
138+
inputs:
139+
investigation_id: 'agent-{{metadata.start_time}}'
140+
topic: '{{blocks.classify_task.outputs.response_json.parameters.investigation_topic ?? inputs.task_description}}'
141+
file_pattern: '{{blocks.classify_task.outputs.response_json.parameters.file_pattern ?? "*.py"}}'
142+
max_files: 10
143+
depth: moderate
144+
llm_profile: '{{inputs.llm_profile}}'
145+
condition: '{{blocks.classify_task.outputs.response_json.task_type}} == "investigation"'
146+
depends_on: [classify_task]
147+
148+
# Route 2d: Feature Implementation (NEW - uses Layer 3 implementation-planner)
149+
- id: execute_feature_implementation
150+
type: Workflow
151+
inputs:
152+
workflow: implementation-planner
153+
inputs:
154+
task:
155+
title: '{{blocks.classify_task.outputs.response_json.parameters.feature_title ?? "Feature Implementation"}}'
156+
description: '{{inputs.task_description}}'
157+
requirements: '{{blocks.classify_task.outputs.response_json.parameters.requirements ?? "See description"}}'
158+
constraints: '{{blocks.classify_task.outputs.response_json.parameters.constraints ?? "None specified"}}'
159+
codebase_context: 'Project workspace: {{inputs.workspace}}'
160+
llm_profile: '{{inputs.llm_profile}}'
161+
condition: '{{blocks.classify_task.outputs.response_json.task_type}} == "feature_implementation"'
162+
depends_on: [classify_task]
163+
164+
# Route 2e: General Query (using user's profile)
165+
- id: execute_general
166+
type: LLMCall
167+
inputs:
168+
profile: '{{inputs.llm_profile}}'
169+
prompt: '{{inputs.task_description}}'
170+
system_instructions: |
171+
You are a helpful coding assistant.
172+
Provide clear, concise, and accurate responses.
173+
timeout: 60
174+
condition: '{{blocks.classify_task.outputs.response_json.task_type}} == "general"'
175+
depends_on: [classify_task]
176+
177+
# Combine execution results (at least one will have executed)
178+
- id: execute_task
179+
type: Shell
180+
inputs:
181+
command: |
182+
set -euo pipefail
183+
184+
TASK_TYPE="{{blocks.classify_task.outputs.response_json.task_type}}"
185+
186+
echo "Task type: $TASK_TYPE"
187+
188+
case "$TASK_TYPE" in
189+
bug_investigation)
190+
RESULT="{{blocks.execute_bug_investigation.succeeded}}"
191+
;;
192+
code_review)
193+
RESULT="{{blocks.execute_code_review.succeeded}}"
194+
;;
195+
investigation)
196+
RESULT="{{blocks.execute_investigation.succeeded}}"
197+
;;
198+
feature_implementation)
199+
RESULT="{{blocks.execute_feature_implementation.succeeded}}"
200+
;;
201+
general)
202+
RESULT="{{blocks.execute_general.succeeded}}"
203+
;;
204+
esac
205+
206+
echo "Execution result: $RESULT"
207+
depends_on:
208+
- block: execute_bug_investigation
209+
required: false
210+
- block: execute_code_review
211+
required: false
212+
- block: execute_investigation
213+
required: false
214+
- block: execute_feature_implementation
215+
required: false
216+
- block: execute_general
217+
required: false
218+
219+
# Phase 3: Final Summary
220+
- id: final_summary
221+
type: Shell
222+
inputs:
223+
command: |
224+
set -euo pipefail
225+
226+
echo "========================================"
227+
echo "Code Assistant Agent - Complete"
228+
echo "========================================"
229+
echo ""
230+
echo "User Request: {{inputs.task_description}}"
231+
echo ""
232+
echo "Task Classification:"
233+
echo " Type: {{blocks.classify_task.outputs.response_json.task_type}}"
234+
echo " Confidence: {{blocks.classify_task.outputs.response_json.confidence}}"
235+
echo " Reasoning: {{blocks.classify_task.outputs.response_json.reasoning}}"
236+
echo ""
237+
echo "Execution:"
238+
echo " Status: {{blocks.execute_task.succeeded ? '✅ Completed' : '❌ Failed'}}"
239+
echo ""
240+
241+
case "{{blocks.classify_task.outputs.response_json.task_type}}" in
242+
bug_investigation)
243+
if [ "{{blocks.execute_bug_investigation.succeeded}}" = "true" ]; then
244+
echo "Bug Investigation Results:"
245+
echo " Investigation Path: {{blocks.execute_bug_investigation.outputs.investigation_path}}"
246+
echo " Bug Identified: {{blocks.execute_bug_investigation.outputs.bug_identified}}"
247+
echo " Validation: {{blocks.execute_bug_investigation.outputs.validation_passed}}"
248+
fi
249+
;;
250+
code_review)
251+
if [ "{{blocks.execute_code_review.succeeded}}" = "true" ]; then
252+
echo "Code Review Results:"
253+
echo " Risk Level: {{blocks.execute_code_review.outputs.risk_level}}"
254+
echo " Breaking Changes: {{blocks.execute_code_review.outputs.breaking_changes_count}}"
255+
echo " Approval: {{blocks.execute_code_review.outputs.approval_recommended ? '✅ Recommended' : '⚠️ Not Recommended'}}"
256+
echo " Validation: {{blocks.execute_code_review.outputs.validation_passed ? '✅ Passed' : '❌ Failed'}}"
257+
fi
258+
;;
259+
investigation)
260+
if [ "{{blocks.execute_investigation.succeeded}}" = "true" ]; then
261+
echo "Investigation Results:"
262+
echo " Path: {{blocks.execute_investigation.outputs.investigation_path}}"
263+
echo " Status: {{blocks.execute_investigation.outputs.status}}"
264+
echo " Files Analyzed: {{blocks.execute_investigation.outputs.files_analyzed}}"
265+
echo " Approach: {{blocks.execute_investigation.outputs.approach_used}}"
266+
fi
267+
;;
268+
feature_implementation)
269+
if [ "{{blocks.execute_feature_implementation.succeeded}}" = "true" ]; then
270+
echo "Implementation Plan Results:"
271+
echo " Plan ID: {{blocks.execute_feature_implementation.outputs.plan_id}}"
272+
echo " Chosen Approach: {{blocks.execute_feature_implementation.outputs.chosen_approach}}"
273+
echo " Subtasks: {{blocks.execute_feature_implementation.outputs.subtasks | length}} tasks identified"
274+
echo " Estimated Timeline: {{blocks.execute_feature_implementation.outputs.estimated_days.timeline.estimated_days}} days"
275+
echo " Risks Identified: {{blocks.execute_feature_implementation.outputs.risks | length}}"
276+
echo " Plan State: {{blocks.execute_feature_implementation.outputs.plan_state_path}}"
277+
echo ""
278+
echo "Next Steps:"
279+
echo " 1. Review plan at: {{blocks.execute_feature_implementation.outputs.plan_state_path}}"
280+
echo " 2. Validate approach with team"
281+
echo " 3. Begin implementation following execution order"
282+
fi
283+
;;
284+
general)
285+
if [ "{{blocks.execute_general.succeeded}}" = "true" ]; then
286+
echo "Response:"
287+
echo "{{blocks.execute_general.outputs.response}}"
288+
fi
289+
;;
290+
esac
291+
292+
echo ""
293+
echo "Agent execution complete"
294+
depends_on: [execute_task]

0 commit comments

Comments
 (0)