Skip to content

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 2 times, most recently 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
@vrtnis vrtnis force-pushed the feat/run-lifecycle-interrupt-update branch 2 times, most recently from ffcdd94 to 0d119fa Compare August 25, 2025 06:12
@seratch seratch added the enhancement New feature or request label Aug 26, 2025
@seratch
Copy link
Member

seratch commented Aug 26, 2025

Thanks for sending this PR. This pull request brings lots of changes, so I am not sure if it really resolves the issue/need. I don't have the bandwidth to check this PR right now, but our team may be able to look into this soon.

@seratch seratch marked this pull request as draft August 26, 2025 04:24
@vrtnis
Copy link
Contributor Author

vrtnis commented Aug 26, 2025

All good, no worries, :) happy to jump in whenever the team has time and it aligns with the roadmap

@tauzhang-cn
Copy link

this is a very helpful feature, thank you for the PR!

@vrtnis vrtnis force-pushed the feat/run-lifecycle-interrupt-update branch 4 times, most recently from 7e72942 to d4895e2 Compare September 5, 2025 19:04
@vrtnis vrtnis force-pushed the feat/run-lifecycle-interrupt-update branch from d4895e2 to ac2909c Compare September 5, 2025 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature:core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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