-
Notifications
You must be signed in to change notification settings - Fork 46k
feat(copilot): add goal decomposition step before agent building #12731
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
97 commits
Select commit
Hold shift + click to select a range
2619591
fix(backend/copilot): skip AI blocks without model property in fix_aiβ¦
goodluck1103 5bb919e
feat(copilot): add task decomposition for agent building
goodluck1103 f330699
fix(copilot): improve decompose_goal UX β pin box post-stream, suppreβ¦
goodluck1103 703d343
chore(frontend): update openapi.json snapshot
goodluck1103 629fb4d
fix(copilot): allow sub-instructions companion text and restore streaβ¦
goodluck1103 aca81f3
Merge branch 'dev' of https://github.com/Significant-Gravitas/AutoGPTβ¦
goodluck1103 5fa3311
feat(copilot): add auto-approve timer with editable steps to decomposβ¦
goodluck1103 b9d47a8
fix(copilot): auto-size editable step textareas on initial render andβ¦
goodluck1103 5e9cee5
fix(copilot): address PR review comments on decompose_goal tool
goodluck1103 9004a3a
fix(copilot): guard auto-approve against race condition when isLastMeβ¦
goodluck1103 70689ce
fix(frontend/copilot): guard isPending flag on error and filter emptyβ¦
goodluck1103 31ce418
fix(backend/copilot): resolve merge conflict with dev branch in modelβ¦
goodluck1103 02b972c
fix(backend/copilot): regenerate openapi.json with TaskDecompositionRβ¦
goodluck1103 8d5e8a9
fix(backend/copilot): add decompose_goal to ToolName Literal in permiβ¦
goodluck1103 94f065a
fix(frontend/copilot): remove setInitialPrompt conflict and reset ediβ¦
goodluck1103 fb86fcb
feat(copilot): add server-side auto-approve fallback for decompose_goal
goodluck1103 f7601d0
fix(copilot): resume decompose_goal countdown from server timestamp
goodluck1103 f467ead
fix(copilot): disable decompose_goal Approve/Modify while message is β¦
goodluck1103 ed98980
fix(copilot): index-based predicate so manual approve cancels server β¦
goodluck1103 fdfd53b
fix(copilot): don't auto-approve decomposition on mount when deadlineβ¦
goodluck1103 2760cb0
Merge remote-tracking branch 'origin/dev' into feat/task-decompositioβ¦
goodluck1103 98470c2
chore(backend): black-format platform_cost_test.py
goodluck1103 ca7dc22
chore(frontend): regenerate openapi.json with TaskDecompositionResponβ¦
goodluck1103 8f5b9fa
fix(copilot): align server auto-approve timer with client at 60s
goodluck1103 7b60e45
feat(copilot): cancel server auto-approve when user clicks Modify + uβ¦
goodluck1103 b2dab8a
fix(copilot): use Redis flag for cross-process auto-approve cancellation
goodluck1103 5f19f6c
fix(copilot): remove client-side auto-approve to prevent duplicate meβ¦
goodluck1103 0840b56
fix(copilot): clear stale Redis cancel flag when scheduling new auto-β¦
goodluck1103 d892b66
fix(copilot): fall back to default approval when all step descriptionβ¦
goodluck1103 6d1cd41
fix(copilot): restore client auto-approve with 5s server grace to fixβ¦
goodluck1103 aa5b84e
style(copilot): reformat auto-approve constants
goodluck1103 020d094
fix(copilot): prevent duplicate auto-approve via DB-backed predicate β¦
goodluck1103 8d102d6
refactor(copilot): remove max 8 steps limit from decompose_goal
goodluck1103 b0c46ff
Merge remote-tracking branch 'origin/dev' into feat/task-decompositioβ¦
goodluck1103 bee1c9a
fix(copilot): resolve merge conflict with dev + improve frontend testβ¦
goodluck1103 ffdafcc
fix(frontend): remove unused DecomposeGoalOutput type import
goodluck1103 35bca7c
fix(copilot): fix task callback race + skip redundant DB existence check
goodluck1103 225bdfb
test(frontend): add integration tests for DecomposeGoal, StepItem, anβ¦
Copilot 62d4748
Merge branch 'dev' into feat/task-decomposition-copilot
goodluck1103 420251c
fix(copilot): clean up stream registry on enqueue failure in auto-appβ¦
goodluck1103 19cd77f
Merge branch 'feat/task-decomposition-copilot' of https://github.com/β¦
goodluck1103 c01c47d
Merge branch 'dev' into feat/task-decomposition-copilot
ntindle 559438f
fix(frontend): run pnpm format on DecomposeGoal test files
Copilot e4a3c4f
style(copilot): reformat test files
goodluck1103 e376db6
Merge branch 'feat/task-decomposition-copilot' of https://github.com/β¦
goodluck1103 480ec70
fix(frontend): remove unused RenderSegment type import
goodluck1103 88b39e4
Merge branch 'dev' into feat/task-decomposition-copilot
goodluck1103 dece04e
Merge remote-tracking branch 'origin/dev' into feat/task-decompositioβ¦
goodluck1103 db36a76
Merge branch 'feat/task-decomposition-copilot' of https://github.com/β¦
goodluck1103 8299948
Merge branch 'dev' into feat/task-decomposition-copilot
goodluck1103 5542f78
Merge branch 'dev' into feat/task-decomposition-copilot
goodluck1103 4d5969d
refactor(copilot): simplify cancel-auto-approve route, derive countdoβ¦
majdyz a31297c
fix(frontend): avoid eager decrement on legacy decompose_goal sessions
majdyz 5b29ff5
fix(backend): invalidate cache on failed write in append_message_if
majdyz 982808c
fix(backend): skip append_message_if when session lock not acquired
majdyz 162c3f0
fix(copilot): enforce decompose_goal approval gate at code level
majdyz d0cb1e9
fix(copilot): require fresh decompose_goal+approval per build request
majdyz 792c788
Merge branch 'dev' into feat/task-decomposition-copilot
majdyz 731748d
Merge remote-tracking branch 'origin/dev' into feat/task-decompositioβ¦
goodluck1103 2b24ef5
fix(copilot): resolve merge conflict with dev + fix test failures
goodluck1103 3523170
Merge remote-tracking branch 'origin/dev' into feat/task-decompositioβ¦
goodluck1103 1ec30ab
refactor(copilot): use run_copilot_turn_via_queue for auto-approve
goodluck1103 40d56ed
fix(copilot): skip server auto-approve when turn is already in flight
goodluck1103 51c16c6
fix(copilot): any user response after decompose_goal unblocks build gate
goodluck1103 00c992a
Merge branch 'dev' into feat/task-decomposition-copilot
goodluck1103 089fc06
Merge remote-tracking branch 'origin/dev' into feat/task-decompositioβ¦
goodluck1103 16a51e5
Merge branch 'feat/task-decomposition-copilot' of https://github.com/β¦
goodluck1103 f8df0fa
Merge remote-tracking branch 'origin/dev' into feat/task-decompositioβ¦
goodluck1103 4fff564
Merge branch 'dev' into feat/task-decomposition-copilot
goodluck1103 95362f7
fix(copilot): timer only ticks after turn fully finishes
goodluck1103 26caa86
Merge branch 'feat/task-decomposition-copilot' of https://github.com/β¦
goodluck1103 263a414
Merge remote-tracking branch 'origin/dev' into feat/task-decompositioβ¦
goodluck1103 b9849ce
Merge branch 'dev' into feat/task-decomposition-copilot
goodluck1103 1549972
fix(copilot): stronger prompt to end turn after decompose_goal
goodluck1103 eedb64a
Merge branch 'feat/task-decomposition-copilot' of https://github.com/β¦
goodluck1103 b1eee6e
fix(copilot): suppress duplicate text when calling decompose_goal
goodluck1103 8023b66
Merge branch 'dev' into feat/task-decomposition-copilot
goodluck1103 dbab590
refactor(copilot): make decompose_goal a visibility-only tool
goodluck1103 b373e37
test(copilot): use complete fixtures for splitReasoningAndResponse tests
goodluck1103 3b7cbe7
test(copilot): add diagnostic logging to helpers.test.ts
goodluck1103 234f05f
test(copilot): deeper diagnostic β compare findLastIndex vs manual loop
goodluck1103 6221761
debug(copilot): instrument splitReasoningAndResponse internals
goodluck1103 59d74fb
fix(copilot): make splitReasoningAndResponse robust to bundler optimiβ¦
goodluck1103 db20387
Merge branch 'dev' of https://github.com/Significant-Gravitas/AutoGPTβ¦
goodluck1103 b42d087
Merge branch 'dev' into feat/task-decomposition-copilot
goodluck1103 24d20a1
Merge branch 'dev' into feat/task-decomposition-copilot
goodluck1103 b48030d
Merge branch 'dev' of https://github.com/Significant-Gravitas/AutoGPTβ¦
goodluck1103 40f1bfc
Merge branch 'dev' of https://github.com/Significant-Gravitas/AutoGPTβ¦
goodluck1103 3b0f62d
Merge remote-tracking branch 'origin/feat/task-decomposition-copilot'β¦
goodluck1103 3d3c891
Resolve merge conflicts with dev
goodluck1103 af04b1d
Merge branch 'dev' into feat/task-decomposition-copilot
goodluck1103 1c75319
Resolve merge conflicts with dev
goodluck1103 b69530d
fix(frontend/copilot): align isErrorOutput with parseOutput for messaβ¦
goodluck1103 1a9bbcf
feat(copilot): make decompose_goal step descriptions plain-English
goodluck1103 7d31292
fix(copilot): tighten decompose_goal descriptions to fit schema char β¦
goodluck1103 2d567b2
Resolve merge conflicts with dev
goodluck1103 8bae482
refactor(frontend/copilot): restore findLastIndex in splitReasoningAnβ¦
majdyz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
145 changes: 145 additions & 0 deletions
145
autogpt_platform/backend/backend/copilot/tools/decompose_goal.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| """DecomposeGoalTool - Breaks agent-building goals into sub-instructions.""" | ||
|
goodluck1103 marked this conversation as resolved.
|
||
|
|
||
| import logging | ||
| from typing import Any | ||
|
|
||
| from backend.copilot.model import ChatSession | ||
|
|
||
| from .base import BaseTool | ||
| from .models import ( | ||
| DecompositionStepModel, | ||
| ErrorResponse, | ||
| TaskDecompositionResponse, | ||
| ToolResponseBase, | ||
| ) | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| # Matches the guide's "4-8 steps max" constraint. | ||
| MAX_STEPS = 8 | ||
| DEFAULT_ACTION = "add_block" | ||
| VALID_ACTIONS = {"add_block", "connect_blocks", "configure", "add_input", "add_output"} | ||
|
|
||
|
|
||
| class DecomposeGoalTool(BaseTool): | ||
| """Tool for decomposing an agent goal into sub-instructions.""" | ||
|
|
||
| @property | ||
| def name(self) -> str: | ||
| return "decompose_goal" | ||
|
|
||
| @property | ||
| def description(self) -> str: | ||
| return ( | ||
| "Break down an agent-building goal into logical sub-instructions. " | ||
| "Each step maps to one task (e.g. add a block, wire connections, " | ||
| "configure settings). ALWAYS call this before create_agent to show " | ||
| "the user your plan and get approval." | ||
| ) | ||
|
|
||
| @property | ||
| def parameters(self) -> dict[str, Any]: | ||
| return { | ||
| "type": "object", | ||
| "properties": { | ||
| "goal": { | ||
| "type": "string", | ||
| "description": "The user's agent-building goal.", | ||
| }, | ||
| "steps": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "object", | ||
| "properties": { | ||
| "description": { | ||
| "type": "string", | ||
| "description": "Human-readable step description.", | ||
| }, | ||
| "action": { | ||
| "type": "string", | ||
| "description": ( | ||
| "Action type: 'add_block', 'connect_blocks', " | ||
|
goodluck1103 marked this conversation as resolved.
|
||
| "'configure', 'add_input', 'add_output'." | ||
| ), | ||
| "enum": list(VALID_ACTIONS), | ||
| }, | ||
| "block_name": { | ||
| "type": "string", | ||
| "description": "Block name if adding a block.", | ||
| }, | ||
| }, | ||
| "required": ["description", "action"], | ||
| }, | ||
| "description": "List of sub-instructions for the plan.", | ||
| }, | ||
| }, | ||
| "required": ["goal", "steps"], | ||
| } | ||
|
|
||
| async def _execute( | ||
| self, | ||
| user_id: str | None, | ||
|
goodluck1103 marked this conversation as resolved.
|
||
| session: ChatSession, | ||
| goal: str | None = None, | ||
| steps: list[Any] | None = None, | ||
| **kwargs, | ||
| ) -> ToolResponseBase: | ||
| session_id = session.session_id if session else None | ||
|
|
||
| if not goal: | ||
| return ErrorResponse( | ||
| message="Please provide a goal to decompose.", | ||
| error="missing_goal", | ||
| session_id=session_id, | ||
| ) | ||
|
|
||
| if not steps: | ||
| return ErrorResponse( | ||
| message="Please provide at least one step in the plan.", | ||
|
goodluck1103 marked this conversation as resolved.
|
||
| error="missing_steps", | ||
|
goodluck1103 marked this conversation as resolved.
|
||
| session_id=session_id, | ||
| ) | ||
|
goodluck1103 marked this conversation as resolved.
|
||
|
|
||
| if len(steps) > MAX_STEPS: | ||
| return ErrorResponse( | ||
| message=f"Too many steps ({len(steps)}). Keep the plan to {MAX_STEPS} steps max.", | ||
|
goodluck1103 marked this conversation as resolved.
Outdated
|
||
| error="too_many_steps", | ||
| session_id=session_id, | ||
| ) | ||
|
|
||
| decomposition_steps: list[DecompositionStepModel] = [] | ||
| for i, step in enumerate(steps): | ||
| if not isinstance(step, dict): | ||
| return ErrorResponse( | ||
| message=f"Step {i + 1} is malformed β expected an object.", | ||
| error="invalid_step", | ||
| session_id=session_id, | ||
| ) | ||
| description = step.get("description", "") | ||
| if not description or not description.strip(): | ||
| return ErrorResponse( | ||
|
goodluck1103 marked this conversation as resolved.
|
||
| message=f"Step {i + 1} is missing a description.", | ||
| error="empty_description", | ||
| session_id=session_id, | ||
| ) | ||
| action = step.get("action", DEFAULT_ACTION) | ||
| if action not in VALID_ACTIONS: | ||
| action = DEFAULT_ACTION | ||
| decomposition_steps.append( | ||
| DecompositionStepModel( | ||
| step_id=f"step_{i + 1}", | ||
| description=description, | ||
| action=action, | ||
| block_name=step.get("block_name"), | ||
| status="pending", | ||
| ) | ||
| ) | ||
|
|
||
| return TaskDecompositionResponse( | ||
| message=f"Here's the plan to build your agent ({len(decomposition_steps)} steps):", | ||
| goal=goal, | ||
| steps=decomposition_steps, | ||
| step_count=len(decomposition_steps), | ||
| requires_approval=True, | ||
| session_id=session_id, | ||
| ) | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.