rebunoFetch, so every model call is recorded as an llm_call
step, and tools run through defineTool, so every tool call is recorded as a
tool_call step. On a re-dispatch the agent runs from the top and recorded
steps replay instead of calling the model or the tool again.
Install
Model calls
ChatOpenAI passes configuration through to the OpenAI client, which accepts
a custom fetch. Pass rebunoFetch:
Tools
Declare the Rebuno side withdefineTool, and call it from a LangChain tool:
at_most_once. See idempotency.
Stopping on approval
When a tool is held for approval, it throws. The agent loop passes a tool error back to the model and keeps looping, and every model call after that is refused. Abort the loop on the first tool error instead, by catching it in the tool and aborting a signal passed toinvoke. The agent below does this.
The agent
What Rebuno adds
- Policy. Every model and tool call is checked against policy before it runs. A denied tool returns the rule’s reason to the model as the tool result, so the agent can take a different path.
- Approvals. A tool that requires approval parks the execution. Once it’s approved, the agent is dispatched again, the earlier steps replay, and the approved call runs.
- Recovery. If the worker dies partway through, the next dispatch replays every completed step and continues from the first one that didn’t finish. Model calls that already ran are not paid for twice.
Full example
examples/frameworks/typescript/langchain_agent.ts
is a support agent that investigates a customer issue, creates a ticket, and
emails a summary after approval.