Skip to content

Conversation

@declanjackson
Copy link
Collaborator

Add Agent Run Cache

  • Add caching and resumption functionality for agent tasks
  • Automatically cache agent state (conversation history, execution environment files) on interruption (Ctrl+C, error, or max turns reached)
  • Enable resumption via resume=True parameter on session() - if a cache exists for the same prompt, the agent restores state and continues from the last turn
  • Cache is keyed by SHA256 hash of initial messages and stored in ~/.cache/stirrup/<task_hash>/

How to test/use:

Enable resumption: Pass resume=True to session():

async with agent.session(output_dir="./output", resume=True) as session:
     await session.run("Analyze all datasets")

Preserve cache after success: Set clear_cache_on_success=False to keep cache for debugging:

async with agent.session(resume=True, clear_cache_on_success=False) as session:
    await session.run("Long running task")

Files changed

File Change
src/stirrup/core/cache.py New - Cache module with CacheState, CacheManager, and serialization helpers
src/stirrup/core/agent.py Modified - Added resume/cache logic, signal handling for graceful interruption
src/stirrup/tools/code_backends/base.py Modified - Added temp_dir property to base class
docs/guides/caching.md New - Documentation for the caching feature
mkdocs.yml Modified - Added caching guide to navigation

@declanjackson declanjackson merged commit 717bb1e into main Jan 9, 2026
2 checks passed
@declanjackson declanjackson deleted the feat/add_run_cache branch January 9, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants