Skip to content

Capture partial messages and usage when tasks are cancelled #44

@dedeswim

Description

@dedeswim

Currently when a task is cancelled (Ctrl+C), we record the cancellation but cannot save the partial messages and token usage accumulated up to that point.

The agent's run() method uses a simple iteration pattern that doesn't expose intermediate state:

async for state in self.iter(...):
    result_state = state
return result_state.run_ctx

To capture partial state, we would need to either:

  1. Store the last yielded state in an instance variable accessible on cancellation
  2. Implement streaming with real-time state callbacks

This would be useful for debugging cancelled runs and understanding how far execution progressed before interruption.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions