Skip to content

fix: write orchestrator failure reasons to task_logs.json (#1978)#2005

Open
octo-patch wants to merge 1 commit intoAndyMik90:developfrom
octo-patch:fix/issue-1978-planning-error-blank-messages
Open

fix: write orchestrator failure reasons to task_logs.json (#1978)#2005
octo-patch wants to merge 1 commit intoAndyMik90:developfrom
octo-patch:fix/issue-1978-planning-error-blank-messages

Conversation

@octo-patch
Copy link
Copy Markdown

@octo-patch octo-patch commented Apr 10, 2026

Fixes #1978

Problem

After the Vercel AI SDK v6 migration, planning phase errors show as red "error" badges in the Logs tab with completely empty detail messages. When SpecOrchestrator or BuildOrchestrator fails (e.g., "Model completed session without making any tool calls — expected files not created: context.json"), the error string in outcome.error was emitted as a PLANNING_FAILED task event but never written to task_logs.json.

Solution

Explicitly write outcome.error to the log writer as an error entry before closing the active phase, in both runSpecOrchestrator and runBuildOrchestrator in worker.ts. These orchestrator-level failures don't flow through the onEvent stream callback, so they need to be written at the point where outcome.error is first available.

Testing

  • Create a task where planning fails (e.g., using a model that doesn't call tools)
  • Check the Logs tab — error entries should now show the actual failure message instead of blank text

Summary by CodeRabbit

  • Bug Fixes
    • Improved error logging in the AI agent to ensure error messages from build and specification workflows are properly captured and recorded in task logs, providing better visibility into agent operation failures and supporting improved troubleshooting.

…Mik90#1978)

When the SpecOrchestrator or BuildOrchestrator fails (e.g. "Model
completed session without making any tool calls — expected files not
created: context.json"), the error string in outcome.error was emitted
as a PLANNING_FAILED task event but never written to task_logs.json.
This caused the Logs tab to show red "error" badges with no message text.

Fix by writing outcome.error to the log writer as an 'error' entry
before closing the active phase, in both runSpecOrchestrator and
runBuildOrchestrator. These orchestrator-level failures don't flow
through the onEvent stream callback, so they need to be written
explicitly at the point where outcome.error is first available.
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


octo-patch seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9242547d-e790-4e1d-ad12-7e9fd09e5b3d

📥 Commits

Reviewing files that changed from the base of the PR and between cba7a02 and a4dca98.

📒 Files selected for processing (1)
  • apps/desktop/src/main/ai/agent/worker.ts

📝 Walkthrough

Walkthrough

The change adds error logging to orchestrator functions in the agent worker. Before closing log phases in runBuildOrchestrator and runSpecOrchestrator, the code now writes error messages from failed outcomes to task logs, ensuring error details are captured when outcomes don't propagate through event streams.

Changes

Cohort / File(s) Summary
Error Logging in Orchestrators
apps/desktop/src/main/ai/agent/worker.ts
Added conditional error message logging before phase termination in both runBuildOrchestrator (mapping active phases to log phases) and runSpecOrchestrator to record error details in task logs when outcomes are unsuccessful.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hops of joy for errors now shown,
No more blank details left alone,
When orchestras stumble and fail,
Their stories we faithfully tell,
Each log now sings the truth it's been owed!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: writing orchestrator failure reasons to task_logs.json, which directly addresses the core issue.
Linked Issues check ✅ Passed The code changes directly implement the requirement to write outcome.error to task logs before closing phases in both orchestrators, ensuring error messages appear in task_logs.json.
Out of Scope Changes check ✅ Passed All changes are scoped to writing error messages to task logs in the two orchestrator functions, with no extraneous modifications present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the build and spec orchestrators to log failure reasons directly to the UI when an outcome is unsuccessful, ensuring that build-level and spec-level validation errors are visible in the Logs tab. I have reviewed the changes and suggest consolidating the phase-mapping logic in the build orchestrator into a helper function to reduce duplication with the existing terminal state cleanup block.

Comment on lines +684 to +692
if (!outcome.success && outcome.error) {
const data = logWriter.getData();
const activePhase = (['validation', 'coding', 'planning'] as const).find(
(p) => data.phases[p]?.status === 'active'
);
const errorPhase: 'qa' | 'coding' | 'planning' =
activePhase === 'validation' ? 'qa' : (activePhase ?? 'planning');
logWriter.logText(outcome.error, errorPhase, 'error');
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The logic for identifying the active phase and mapping it to a Phase type is correct and ensures that orchestrator-level errors are attributed to the correct log section. However, note that this logic for finding and mapping the active phase is partially duplicated in the terminal state cleanup block (lines 699-705). While not a bug, consolidating this into a helper or a shared variable within the if (logWriter) block would improve maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Planning phase errors have blank detail messages after Vercel AI SDK migration

2 participants