Skip to content

fix(orchestrator): capture final output for webhook dispatch#342

Merged
vincentgrobler merged 1 commit intomainfrom
fix/orchestrator-capture-final-output
Apr 9, 2026
Merged

fix(orchestrator): capture final output for webhook dispatch#342
vincentgrobler merged 1 commit intomainfrom
fix/orchestrator-capture-final-output

Conversation

@vincentgrobler
Copy link
Copy Markdown
Collaborator

@vincentgrobler vincentgrobler commented Apr 9, 2026

Description

Root cause: when the brain calls final_answer, the output was saved to the DB via finalizeRun but never captured into the finalOutput variable used by the webhook dispatch. The previous fix passed runOutput to the dispatcher, but runOutput was fetched from DB and could be null due to timing. Also the original code returned 'Final answer submitted.' instead of the actual output from the final_answer tool result.

Changes:

  • Track finalOutput at function scope, set it in all three finalization paths: no-tool-call, final_answer tool, and loop exhaustion
  • Capture toolResult.result into finalOutput when isDone is true
  • Return actual output from final_answer case (not placeholder string)
  • Add error checking to finalizeRun's DB update
  • Add debug logging for output lengths at key points
  • Fall back to DB fetch only if inline tracking missed it

Related Issue

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📝 Documentation update
  • ♻️ Refactor (no functional changes)
  • 🧪 Test update

How Has This Been Tested?

  • Unit tests
  • Manual testing
  • Browser testing (specify browsers)

Screenshots (if applicable)

Checklist

  • My code follows the project's coding standards
  • I have run npm run lint and there are no errors
  • I have run npm run test and all tests pass
  • I have added tests for my changes (if applicable)
  • I have updated the documentation (if applicable)
  • My source files have AGPL licence headers
  • My changes generate no new TypeScript errors

Root cause: when the brain calls final_answer, the output was saved to
the DB via finalizeRun but never captured into the finalOutput variable
used by the webhook dispatch. The previous fix passed runOutput to the
dispatcher, but runOutput was fetched from DB and could be null due to
timing. Also the original code returned 'Final answer submitted.'
instead of the actual output from the final_answer tool result.

Changes:
- Track finalOutput at function scope, set it in all three finalization
  paths: no-tool-call, final_answer tool, and loop exhaustion
- Capture toolResult.result into finalOutput when isDone is true
- Return actual output from final_answer case (not placeholder string)
- Add error checking to finalizeRun's DB update
- Add debug logging for output lengths at key points
- Fall back to DB fetch only if inline tracking missed it
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
crewform Ready Ready Preview, Comment Apr 9, 2026 0:13am

@vincentgrobler vincentgrobler merged commit bfbffa5 into main Apr 9, 2026
8 checks passed
@vincentgrobler vincentgrobler deleted the fix/orchestrator-capture-final-output branch April 9, 2026 12:14
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.

1 participant