Skip to content

Enforce agent state transitions at compile time via enum-carried data#77

Open
tcdent wants to merge 2 commits intomainfrom
claude/agent-state-enforcement-eJHO9
Open

Enforce agent state transitions at compile time via enum-carried data#77
tcdent wants to merge 2 commits intomainfrom
claude/agent-state-enforcement-eJHO9

Conversation

@tcdent
Copy link
Copy Markdown
Owner

@tcdent tcdent commented Apr 2, 2026

Move state-specific fields (active_stream, pending_tool_calls,
tool_responses) into StreamState enum variants so the compiler prevents
accessing data that only exists in a particular state. This eliminates
runtime state guards in submit_tool_result and makes invalid field
access a compile error rather than a logic bug.

https://claude.ai/code/session_014n42dEnaKvcjB6Qj4Pw7PM

claude added 2 commits April 2, 2026 02:36
Move state-specific fields (active_stream, pending_tool_calls,
tool_responses) into StreamState enum variants so the compiler prevents
accessing data that only exists in a particular state. This eliminates
runtime state guards in submit_tool_result and makes invalid field
access a compile error rather than a logic bug.

https://claude.ai/code/session_014n42dEnaKvcjB6Qj4Pw7PM
Move streaming_text, streaming_thinking, mode, and retry_attempt out of
Agent into a TurnState struct. These fields only exist while processing
a request and are dead weight when idle. Agent now has phase/turn as
paired Options (both Some while processing, both None when idle) rather
than scattered loose fields.

Also capture last_result on turn completion so last_message() works
after the turn state is consumed.

https://claude.ai/code/session_014n42dEnaKvcjB6Qj4Pw7PM
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