Skip to content

fix(backend): prevent graph execution stuck + steer SDK away from bash_exec - #12548

Merged
majdyz merged 6 commits into
devfrom
fix/copilot-tool-results-guidance
Mar 25, 2026
Merged

fix(backend): prevent graph execution stuck + steer SDK away from bash_exec#12548
majdyz merged 6 commits into
devfrom
fix/copilot-tool-results-guidance

Conversation

@majdyz

@majdyz majdyz commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Two backend fixes for CoPilot stability:

  1. Steer model away from bash_exec for SDK tool-result files — When the SDK returns tool results as file paths, the copilot model was attempting to use bash_exec to read them instead of treating the content directly. Added system prompt guidance to prevent this.

  2. Guard against missing 'name' in execution input_dataGraphExecution.from_db() assumed all INPUT/OUTPUT block node executions have a name field in input_data. This crashes with KeyError: 'name' when non-standard blocks (e.g., OrchestratorBlock) produce node executions without this field. Added "name" in exec.input_data guards.

Why

  • The bash_exec issue causes copilot to fail when processing SDK tool outputs
  • The KeyError crashes the update_graph_execution_stats endpoint, causing graph executions to appear stuck (retries 35+ times, never completes)

How

  • Added system prompt instruction to treat tool result file contents directly
  • Added "name" in exec.input_data guard in both input extraction (line 340) and output extraction (line 365) in execution.py

Changes

  • backend/copilot/sdk/service.py — system prompt guidance
  • backend/data/execution.py — KeyError guard for missing name field

Checklist 📋

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan

Test plan:

  • OrchestratorBlock graph execution no longer gets stuck
  • Standard Agent Input/Output blocks still work correctly
  • Copilot SDK tool results are processed without bash_exec

…sult files

The model was using bash_exec (cd + cat) to read SDK tool-result files
under ~/.claude/projects/.../tool-results/, which fails in E2B because
the sandbox runs as /home/user and cannot access /root/. The Read tool
handles these correctly by reading from the host filesystem.

Changes:
- Add "CANNOT read SDK tool-result files" warning to bash_exec description
- Add tool-results mention to the Read tool description
- Fix system prompt: replace stale "read_file" reference with "Read",
  explicitly warn that bash_exec cannot access host-side tool-results
@majdyz
majdyz requested a review from a team as a code owner March 25, 2026 05:52
@majdyz
majdyz requested review from 0ubbe and Swiftyos and removed request for a team March 25, 2026 05:52
@github-project-automation github-project-automation Bot moved this to 🆕 Needs initial review in AutoGPT development kanban Mar 25, 2026
@github-actions github-actions Bot added platform/backend AutoGPT Platform - Back end size/m labels Mar 25, 2026
@coderabbitai

coderabbitai Bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Updated copilot prompting and tool descriptions to require using the Read tool (not bash_exec or read_workspace_file) for SDK tool-result files under ~/.claude/projects/.../tool-results/, clarified those files are on the host filesystem (inaccessible to sandboxed bash_exec), and made a defensive fix in GraphExecution.from_db to only use exec.input_data["name"] when "name" exists.

Changes

Cohort / File(s) Summary
Prompt & storage guidance
autogpt_platform/backend/backend/copilot/prompting.py
Narrowed and corrected _build_storage_supplement: mandates using Read only for SDK tool-result files, disallows bash_exec/read_workspace_file, and clarifies files live on host FS under ~/.claude/projects/.../tool-results/ (not accessible from sandboxed bash_exec).
Read tool description
autogpt_platform/backend/backend/copilot/sdk/tool_adapter.py
Appended explicit instruction to _READ_TOOL_DESCRIPTION to use Read (not bash_exec) for SDK tool-result files under ~/.claude/projects/.../tool-results/.
Bash exec description
autogpt_platform/backend/backend/copilot/tools/bash_exec.py
Updated BashExecTool.description to state it CANNOT read SDK tool-result files under ~/.claude/projects/... and to direct use of Read; no execution logic changed.
Execution data defensive fix
autogpt_platform/backend/backend/data/execution.py
Made GraphExecution.from_db defensive: when building inputs and outputs from completed INPUT/OUTPUT block executions, only access exec.input_data["name"] if "name" exists, avoiding unsafe indexing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

size/s, Review effort 3/5

Suggested reviewers

  • 0ubbe
  • Swiftyos
  • Bentlybro

Poem

🐰 I hopped through prompts and filesystem trails,
Told bash to step back from host-side tales.
"Use Read," I hummed, nose twitching with glee,
Guarding tool-results where humans can't see —
A little rabbit's helpful decree.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the two main fixes: preventing graph execution from getting stuck and steering the model away from bash_exec for SDK tool-result files.
Description check ✅ Passed The description comprehensively details both fixes with clear sections on summary, rationale, implementation, and test plans that directly relate to the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/copilot-tool-results-guidance

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@majdyz majdyz left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Self-review Summary

All three changes are consistent and reinforce each other — system prompt, Read tool description, and bash_exec description all point the model in the right direction.

No blockers or should-fix issues found.

🟡 Nice to Have (pre-existing, not in diff): Line 187 of prompting.py says "SDK file tools (Read/Write/Edit/Glob/Grep) and bash_exec share one filesystem" — slightly misleading now since Read can also access host-side tool-result files that bash_exec cannot. Could add a qualifier in a follow-up.

majdyz added 3 commits March 25, 2026 12:53
Address self-review: the "Shell & filesystem" section listed Read
alongside bash_exec as sharing one filesystem, which is misleading now
that Read also accesses host-side SDK tool-result files.
Read shares the sandbox filesystem for regular files; it just
additionally reads host-side tool-results. Removing it from the list
was misleading. The tool-results section below already covers the
distinction.
Prevents KeyError when node executions from non-standard blocks
(e.g., OrchestratorBlock) don't include 'name' in input_data.
The from_db fallback assumes all INPUT/OUTPUT block executions have
a 'name' field, but this isn't guaranteed for all block types.
@majdyz majdyz changed the title fix(backend/copilot): steer model away from bash_exec for SDK tool-result files fix(backend): prevent graph execution stuck + steer SDK away from bash_exec Mar 25, 2026
majdyz added 2 commits March 25, 2026 13:31
…m prompt only

Remove redundant tool-results mentions from Read and bash_exec tool
descriptions — the system prompt storage supplement already covers this
clearly. Avoids wasting tokens on triple-repeated instructions.
@majdyz
majdyz enabled auto-merge March 25, 2026 06:39
@majdyz
majdyz disabled auto-merge March 25, 2026 06:58
@majdyz
majdyz merged commit 336114f into dev Mar 25, 2026
25 checks passed
@majdyz
majdyz deleted the fix/copilot-tool-results-guidance branch March 25, 2026 06:58
@github-project-automation github-project-automation Bot moved this from 🆕 Needs initial review to ✅ Done in AutoGPT development kanban Mar 25, 2026
@majdyz
majdyz removed request for 0ubbe and Swiftyos March 25, 2026 06:58
Comment thread autogpt_platform/backend/backend/data/execution.py
Comment thread autogpt_platform/backend/backend/data/execution.py
majdyz added a commit that referenced this pull request Mar 25, 2026
Revert the early-continue refactor and logger.debug — debug logs aren't
read in production. Keep the simple inline guard style from the original
PR #12548.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/backend AutoGPT Platform - Back end size/m

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

1 participant