Skip to content

Clarify the error when there's no active agent run - #370

Merged
anbuzin merged 1 commit into
mainfrom
clarify-hook-runtime-error
Nov 18, 2026
Merged

anbuzin merged 1 commit into
mainfrom
clarify-hook-runtime-error

Conversation

@anbuzin

@anbuzin anbuzin commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

If you call ai.hook or ai.yield_from outside an agent run, you still get a LookupError, but it now tells you where to call it instead of showing a ContextVar. The ai.hook docstring now says metadata goes in the emitted HookPart.

Calling hook or yield_from outside a running loop exposed the repr of
a ContextVar. Raise LookupError with a sentence that explains where the
call belongs, without changing the exception type.

Cover both callers and the runtime getter. Also describe hook metadata
as part of the emitted HookPart rather than an obsolete checkpoint.
@anbuzin anbuzin added the fix Bug fix label Nov 17, 2026
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
ai-python Ready Ready Preview, v0 Nov 17, 2026 11:53pm UTC

@anbuzin
anbuzin merged commit a6804de into main Nov 18, 2026
14 checks passed
@anbuzin
anbuzin deleted the clarify-hook-runtime-error branch November 18, 2026 18:54

This branch was successfully deployed

1 active deployment
Preview — 219d29eb Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants