Skip to content

feat(agent): Add session resumption support#335

Merged
edenreich merged 1 commit intomainfrom
feat/agent-session-resumption
Dec 11, 2025
Merged

feat(agent): Add session resumption support#335
edenreich merged 1 commit intomainfrom
feat/agent-session-resumption

Conversation

@edenreich
Copy link
Contributor

Summary

Adds session resumption support to the agent command, allowing users to continue work from where they left off.

Changes

New Features

  • --session-id flag: Resume existing agent sessions by conversation ID
  • Session lifecycle events: Structured JSON status messages for session events
  • Conversation loading: Load and restore full conversation history from database
  • Turn counter reset: Full budget restored when resuming sessions

Implementation Details

  1. convertFromConversationEntry: Reverse conversion from domain.ConversationEntry to ConversationMessage
  2. loadExistingSession: Load conversation from persistent repository and restore state
  3. outputStatusMessage: Output structured JSON for session lifecycle events
  4. Session ID preservation: Maintain session ID for continued persistence

Documentation Updates

  • Updated README.md with session resumption examples
  • Enhanced commands-reference.md with detailed usage and JSON examples
  • Added session resumption to feature list

Testing

  • Comprehensive unit tests for convertFromConversationEntry
  • Tests cover all message types: user, assistant, tool, with images, tool calls, and metadata
  • Edge cases: internal messages, tool execution metadata, empty content

Usage Examples

# List conversations to find session IDs
infer conversations list

# Resume an existing session
infer agent "continue fixing the authentication bug" --session-id abc-123-def

# Resume with additional files
infer agent "analyze these new error logs" --session-id abc-123 --files error.log

# Resume without saving (testing mode)
infer agent "try a different approach" --session-id abc-123 --no-save

JSON Status Messages

// Successful resume
{"type":"info","message":"Resumed agent session","session_id":"abc-123","message_count":15,"timestamp":"2025-12-11T..."}

// Failed resume (warning)
{"type":"warning","message":"Could not load session, starting fresh","session_id":"invalid","error":"failed to load conversation: not found","timestamp":"2025-12-11T..."}

// New session
{"type":"info","message":"Starting new agent session","session_id":"new-uuid","model":"openai/gpt-4","timestamp":"2025-12-11T..."}

Benefits

  • Continuity: Continue complex tasks across multiple sessions
  • Context preservation: Maintain full conversation history
  • Efficiency: Avoid repeating setup and context establishment
  • Debugging: Easier to debug and iterate on complex problems
  • Integration: Structured JSON output for automation and monitoring

Technical Notes

  • Uses existing persistent conversation repository infrastructure
  • Maintains backward compatibility (no breaking changes)
  • All existing tests pass
  • Follows existing code patterns and conventions

- Add --session-id flag to resume existing agent sessions
- Implement convertFromConversationEntry for loading saved conversations
- Add loadExistingSession method to restore conversation state
- Add structured JSON status messages for session lifecycle events
- Update documentation with session resumption examples
- Add comprehensive tests for convertFromConversationEntry
@edenreich edenreich changed the title feat(agent): add session resumption support feat(agent): Add session resumption support Dec 11, 2025
@edenreich edenreich merged commit a8942f7 into main Dec 11, 2025
5 checks passed
@edenreich edenreich deleted the feat/agent-session-resumption branch December 11, 2025 18:45
@edenreich edenreich linked an issue Dec 11, 2025 that may be closed by this pull request
4 tasks
ig-semantic-release-bot bot pushed a commit that referenced this pull request Dec 11, 2025
## [0.88.0](v0.87.0...v0.88.0) (2025-12-11)

### 🚀 Features

* Add persistent storage for agent mode conversations ([#333](#333)) ([cba596a](cba596a))
* **agent:** Add session resumption support ([#335](#335)) ([a8942f7](a8942f7))

### 🐛 Bug Fixes

* Improve tool execution status tracking ([#334](#334)) ([95f71cd](95f71cd))
@ig-semantic-release-bot
Copy link

🎉 This PR is included in version 0.88.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] The ability to resume a session in agent mode

1 participant

Comments