Skip to content

feat(run): lifecycle interrupt + live input injection; cancel-aware tools; safer tracing #1557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vrtnis
Copy link
Contributor

@vrtnis vrtnis commented Aug 22, 2025

Included in this PR

Resolves #798

active_run handle on Runner.run and Runner.run_streamed

cancel(reason) for a clean stop

inject(items) included on the next turn

state() for a tiny debug snapshot

Streamed runs emit a cancelled status event and close the queue; non-streamed return a terminal result without final output.

Public APIs stay the same; tracing and hook order are preserved for normal completions.

Tests

New tests cover cancel, inject, and status emission in both streamed and non-streamed paths.

RunState + run_single_step (next step)

What I'm thinking is that this PR lays the groundwork for a proper step API while solving the immediate problem of cancellation and live input injection. The follow-up I’m proposing could perhaps follow this path (all open to discussion!):

Introduce a light RunState that captures current agent, turn, items, and bookkeeping.

Expose run_single_step(state) -> new_state that does “call model → run tools/handoffs → decide next”.

Keep Runner.run* as a thin loop over run_single_step for backward compatibility.

Add step-level tests and examples so folks can drive agents interactively.

If this direction sounds good, I can open a focused PR right after this one that sketches RunState and a minimal run_single_step while maintaining today’s surface.

Happy to make changes to better align with roadmap.

@vrtnis vrtnis force-pushed the feat/run-lifecycle-interrupt-update branch from 502fed9 to aa9f17b Compare August 22, 2025 05:40
@vrtnis vrtnis force-pushed the feat/run-lifecycle-interrupt-update branch from aa9f17b to fac7da7 Compare August 22, 2025 05:45
@vrtnis vrtnis marked this pull request as ready for review August 22, 2025 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Enhanced Run Lifecycle Management - Interrupt and Update Active Runs
2 participants