Skip to content

Commit 382d5a2

Browse files
committed
state: Reset
1 parent b78f8d3 commit 382d5a2

23 files changed

Lines changed: 173 additions & 3257 deletions

build_tools/sharpy_auto_builder/interrupt_handler.py

Lines changed: 99 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ def _display_review_request(data: Dict[str, Any]) -> None:
7373

7474
# Task information
7575
console.print(f"[bold]Task ID:[/bold] {task_id}")
76-
console.print(f"[bold]Description:[/bold] {task_desc}")
76+
# Show task description as rendered markdown in a panel for better readability
77+
if task_desc:
78+
# Truncate description for display but show more than before
79+
desc_display = task_desc[:1500] if len(task_desc) > 1500 else task_desc
80+
console.print(Panel(Markdown(desc_display), title="Task Description", border_style="blue"))
7781
console.print()
7882

7983
# Execution result
@@ -90,6 +94,17 @@ def _display_review_request(data: Dict[str, Any]) -> None:
9094
console.print(f"[red]Error:[/red] {execution_result['error'][:200]}")
9195
console.print()
9296

97+
# Agent output (what the agent actually did/found)
98+
agent_output = execution_result.get("output", "")
99+
if agent_output:
100+
console.print("[bold cyan]═══ Agent Output ═══[/bold cyan]")
101+
console.print()
102+
# Show full output - user can scroll
103+
console.print(Markdown(agent_output))
104+
console.print()
105+
console.print("[bold cyan]═══ End of Agent Output ═══[/bold cyan]")
106+
console.print()
107+
93108
# Files changed
94109
if files_changed:
95110
console.print(f"[bold]Files Changed ({len(files_changed)}):[/bold]")
@@ -218,46 +233,105 @@ def collect_response(interrupt_data: Dict[str, Any]) -> Dict[str, Any]:
218233
interrupt_type = interrupt_data.get("type", "unknown")
219234

220235
if interrupt_type == "review":
221-
return _collect_review_response()
236+
return _collect_review_response(interrupt_data)
222237
elif interrupt_type == "question":
223238
return _collect_question_response(interrupt_data)
224239
else:
225240
console.print(f"[red]Unknown interrupt type: {interrupt_type}[/red]")
226241
return {"error": f"Unknown interrupt type: {interrupt_type}"}
227242

228243

229-
def _collect_review_response() -> Dict[str, Any]:
244+
def _collect_review_response(data: Dict[str, Any]) -> Dict[str, Any]:
230245
"""
231246
Collect user's review decision.
232247
233248
Returns:
234249
Dictionary with approved, retry, feedback fields
235250
"""
251+
# Check if there are actual code changes
252+
files_changed = data.get("files_changed", [])
253+
diff_content = data.get("diff_content", "")
254+
has_code_changes = bool(files_changed) or bool(diff_content)
255+
256+
# Check if agent is asking a follow-up question
257+
agent_output = data.get("execution_result", {}).get("output", "")
258+
asking_followup = any(phrase in agent_output.lower() for phrase in [
259+
"would you like me to",
260+
"shall i",
261+
"do you want me to",
262+
"next steps:",
263+
"what would you like",
264+
])
265+
236266
console.print("[bold yellow]What would you like to do?[/bold yellow]")
237-
console.print(" 1. Approve - Accept the implementation and commit")
238-
console.print(" 2. Retry - Request changes and re-run implementation")
239-
console.print(" 3. Skip - Skip this task and move on")
240-
console.print()
241267

242-
choice = Prompt.ask(
243-
"Enter your choice",
244-
choices=["1", "2", "3", "approve", "retry", "skip"],
245-
default="1",
246-
)
268+
if has_code_changes:
269+
console.print(" 1. Approve - Accept the changes and commit")
270+
console.print(" 2. Retry - Request changes and re-run")
271+
console.print(" 3. Skip - Skip this task and move on")
272+
console.print(" 4. Continue - Mark complete and move to next task (no commit)")
273+
else:
274+
# No code changes - likely an investigation or analysis task
275+
console.print(" 1. Continue - Mark task complete and move to next task")
276+
console.print(" 2. Retry - Re-run with different instructions")
277+
console.print(" 3. Skip - Skip this task")
278+
if asking_followup:
279+
console.print(" 4. Respond - Answer the agent's question")
280+
console.print()
247281

248-
# Normalize choice
249-
if choice in ["1", "approve"]:
250-
approved = True
251-
retry = False
252-
action = "approved"
253-
elif choice in ["2", "retry"]:
254-
approved = False
255-
retry = True
256-
action = "retry requested"
257-
else: # 3 or skip
258-
approved = False
259-
retry = False
260-
action = "skipped"
282+
if has_code_changes:
283+
choices = ["1", "2", "3", "4", "approve", "retry", "skip", "continue"]
284+
default = "1"
285+
else:
286+
choices = ["1", "2", "3", "continue", "retry", "skip"]
287+
if asking_followup:
288+
choices.extend(["4", "respond"])
289+
default = "1"
290+
291+
choice = Prompt.ask("Enter your choice", choices=choices, default=default)
292+
293+
# Normalize choice based on context
294+
if has_code_changes:
295+
if choice in ["1", "approve"]:
296+
approved = True
297+
retry = False
298+
action = "approved"
299+
elif choice in ["2", "retry"]:
300+
approved = False
301+
retry = True
302+
action = "retry requested"
303+
elif choice in ["4", "continue"]:
304+
approved = True # Mark as complete
305+
retry = False
306+
action = "continued (no commit)"
307+
else: # 3 or skip
308+
approved = False
309+
retry = False
310+
action = "skipped"
311+
else:
312+
if choice in ["1", "continue"]:
313+
approved = True
314+
retry = False
315+
action = "completed"
316+
elif choice in ["2", "retry"]:
317+
approved = False
318+
retry = True
319+
action = "retry requested"
320+
elif choice in ["4", "respond"] and asking_followup:
321+
# User wants to respond to agent's question
322+
console.print()
323+
console.print("[bold]Enter your response to the agent:[/bold]")
324+
response_text = Prompt.ask("Response")
325+
return {
326+
"approved": False,
327+
"retry": True,
328+
"feedback": response_text,
329+
"modified_value": None,
330+
}
331+
else: # 3 or skip
332+
approved = False
333+
retry = False
334+
action = "skipped"
261335

262336
# Collect optional feedback
263337
console.print()

build_tools/sharpy_auto_builder/orchestrator/nodes/task_execution.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,15 @@ async def _execute_implementation_node(
168168
and human_response.get("retry")
169169
and human_response.get("feedback")
170170
):
171+
# Include the previous agent output so feedback like "do all 3" makes sense
172+
prev_output = state.get("last_execution_result", {}).get("output", "")
173+
if prev_output:
174+
# Truncate if very long but keep enough context
175+
max_prev_output = 4000
176+
if len(prev_output) > max_prev_output:
177+
prev_output = prev_output[-max_prev_output:] + "\n... [earlier output truncated]"
178+
prompt += f"\n\n## Your Previous Response\n{prev_output}"
179+
171180
prompt += f"\n\n## Human Reviewer Feedback (MUST ADDRESS)\nThe human reviewer requested a retry with the following feedback:\n{human_response['feedback']}\n\nPlease carefully address these concerns in this implementation attempt."
172181

173182
# FEEDBACK LOOP: Include validation issues if we're retrying after validation failure

build_tools/sharpy_auto_builder/state/answers/.gitkeep

Whitespace-only changes.

build_tools/sharpy_auto_builder/state/config.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"project_root": "/Users/anton/Documents/github/sharpy",
3-
"task_list_path": "/Users/anton/github/sharpy/docs/implementation_planning/task_list_0_1_10_module_codegen_fix.md",
3+
"task_list_path": "/Users/anton/Documents/github/sharpy/docs/implementation_planning/task_list_0_1_10_module_codegen_fix.md",
44
"backends": {
55
"claude_code": {
66
"name": "claude_code",
77
"enabled": true,
88
"model": "claude-sonnet-4-5-20250929",
9-
"max_tokens": 200000,
9+
"max_tokens": 16384,
1010
"rate_limit": {
1111
"max_requests_per_window": 50,
1212
"window_seconds": 3600,
@@ -15,9 +15,9 @@
1515
},
1616
"copilot": {
1717
"name": "copilot",
18-
"enabled": true,
18+
"enabled": false,
1919
"model": "claude-sonnet-4-5-20250929",
20-
"max_tokens": 128000,
20+
"max_tokens": 16384,
2121
"rate_limit": {
2222
"max_requests_per_window": 100,
2323
"window_seconds": 3600,
@@ -36,8 +36,8 @@
3636
"max_test_fix_attempts": 3,
3737
"max_validation_fix_attempts": 2,
3838
"create_followup_task_on_fix_failure": true,
39-
"require_human_approval_for_critical": false,
40-
"auto_commit": true,
39+
"require_human_approval_for_critical": true,
40+
"auto_commit": false,
4141
"create_pr": false,
4242
"rate_limit_pause_hours": 3.0,
4343
"test_timeout": 300.0,

build_tools/sharpy_auto_builder/state/execution_log.jsonl

Lines changed: 27 additions & 2189 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)