Skip to content

fix(langchain-agents): accept sync tool handlers - #134

Open
andrewklatzke wants to merge 1 commit into
mainfrom
aklatzke/AIC-3507/fix-lc-handoff
Open

andrewklatzke wants to merge 1 commit into
mainfrom
aklatzke/AIC-3507/fix-lc-handoff

Conversation

@andrewklatzke

@andrewklatzke andrewklatzke commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • LangChain agent tools now run both synchronous and asynchronous handlers. Graph __handoff_* tools stay synchronous so routing records the selected edge instead of raising when the result is awaited.
  • Invoke and stream share _build_agent_tools(), so both routes pick up the same behavior. The graph handoff functions themselves are unchanged.

Fixes AIC-3507.

Test plan

  • A synchronous handler returning a string works
  • An asynchronous handler is still awaited
  • A synthetic __handoff_* handler records and returns its destination
  • Exceptions from either handler type propagate
  • Invoke and streaming routes both execute a sync handoff
  • Full Python suite: 1402 passed, 11 skipped

Made with Cursor

Graph handoff tools stay synchronous so routing can record the selected edge. Awaiting every tool result raised before that record happened.

Co-authored-by: Cursor <cursoragent@cursor.com>
@andrewklatzke

andrewklatzke commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Human message:

Recreated the error on a minimal setup (three nodes, one handoff to each). Made the update then re-ran the graph that was previously failing on the error successfully (it even returned the structured output correctly as configured):

Screenshot 2026-10-02 at 12 58 34 PM Screenshot 2026-10-02 at 12 58 26 PM Screenshot 2026-10-02 at 12 58 29 PM

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