Keep a conversation alive when nobody takes the wheel - #147
Merged
davidmckayv merged 2 commits intoAug 22, 2026
Conversation
A Bot that asks for help with a sign-in and never gets it leaves an assistant message holding a tool call that no tool message ever answers. Every later turn in that thread then dies at the provider with "an assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'", so declining to take the wheel once destroys the conversation for good. Answer the unanswered calls when the history is rebuilt. Each one gets a synthetic tool message saying plainly that no result came, that the run it belonged to has ended, and that the Bot should carry on without it and say what it could not do. The Bot is told the truth rather than a fake success, so it does not report work it never did. The history builder moves to its own module. Importing it from index.ts would bind port 3001, because that file calls serve() at module scope, so a test could not reach it where it was. This mirrors the split agent-computer already makes for control.ts.
davidmckayv
requested review from
MikeRyanDev,
guidovizoso and
tylerslaton
as code owners
August 22, 2026 03:55
Its history tests import @langchain/core, which lives in that Bot's own tree. The Bot is not a root workspace and keeps its own lockfile, so a root install leaves it empty and the test file throws on import. agent-bot already has this step for the same reason.
davidmckayv
deleted the
fix/a-declined-handover-does-not-kill-the-thread
branch
August 22, 2026 04:15
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #140.
What was broken
Ask a Bot to open a page that wants a sign-in and it calls
computer_request_help, which is the right thing to do. If nobody takes the wheel, that tool call is never answered. The assistant message holding it stays in the thread forever with no matching tool message.Every later turn then fails at the provider:
So declining a handover once does not just abandon that one task, it destroys the conversation. Nothing you type afterwards gets an answer, and there is no way back other than starting a new chat.
The fix
When the history is rebuilt for a run, any tool call with no answer gets one: a synthetic tool message placed immediately after the assistant message that made the call.
It says the truth rather than a fake success:
A fake success would have the Bot claim it read a page it never reached. This has it carry on and be honest about the gap.
Why the file moved
toLangChainMessagesnow lives inagent-langgraph/src/history.ts. It was inindex.ts, which callsserve()at module scope, so importing it from a test binds port 3001 and the test cannot run at all.agent-computeralready makes the same split forcontrol.ts.Driven in Chrome
Against a running deployment, in the Browser Bot:
computer_request_help, the take-control prompt appears.Tests
agent-langgraph/tests/history.test.ts, 4 tests, each proven to fail without the change: