Add Phase 7: polish and hardening — retry, truncation, sessions, shutdown
- Config extensions: retry backoff, truncation threshold, session persistence - LLM retry with exponential backoff + jitter on transient errors (5xx, connection) - Conversation truncation: drops oldest messages preserving first user + recent N - Session persistence: auto-save/restore with atomic writes, cleanup of old files - Graceful shutdown: SIGTERM handler, cancel() on AgentLoop, save-on-exit - Partial message recovery on mid-stream interruption - New slash commands: /save, /session - 18 new tests (5 retry, 5 truncation, 4 session, 4 integration workflows) - README.md and docs/tools.md documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -142,6 +142,24 @@ class StreamHandler:
|
||||
)
|
||||
return result
|
||||
|
||||
def get_partial_message(self) -> Message | None:
|
||||
"""Return whatever content/tool_calls have been accumulated so far.
|
||||
|
||||
Useful for mid-stream interruption recovery — returns None if nothing
|
||||
has been accumulated yet.
|
||||
|
||||
Returns:
|
||||
Partial assistant Message, or None if no content accumulated.
|
||||
"""
|
||||
tool_calls = self._build_tool_calls() or None
|
||||
if not self._accumulated_content and not tool_calls:
|
||||
return None
|
||||
return Message(
|
||||
role="assistant",
|
||||
content=self._accumulated_content or None,
|
||||
tool_calls=tool_calls,
|
||||
)
|
||||
|
||||
@property
|
||||
def usage(self) -> TokenUsage | None:
|
||||
"""Token usage reported by the API, if available."""
|
||||
|
||||
Reference in New Issue
Block a user