Skip to content

Improve agent harness with LangGraph-style state machine or Polaris-like architecture #4249

Description

@senamakel-droid

Problem

The current agent harness runs agents in a linear loop — prompt → tool call → result → next prompt. Context is managed through compaction (old turns get summarized and truncated), which is lossy and makes it hard to carry state across long-running agent sessions. The system prompt grows with cross-chat context, active goals, and memory but there's no explicit state-machine architecture to manage transitions, branching, or persistent working state.

Inspiration

LangGraph (LangChain's state graph framework) models agent execution as a directed graph of nodes (states) and edges (transitions). Agents can branch, loop, pause for human input, and resume — all with explicit state that persists across transitions. Key ideas worth adopting:

  • Agent execution as a state machine, not a linear loop
  • Typed state that persists across turns and sub-agent spawns
  • Conditional routing between nodes based on state
  • Checkpointing for pause/resume and human-in-the-loop
  • Sub-graphs for parallel execution and delegation

Polaris (https://github.com/RadiantAILabs/polaris) is another architecture worth studying for inspiration on:

  • How it structures multi-agent coordination
  • How it handles state management across agent boundaries
  • Any novel approaches to context persistence

What could improve

  1. Explicit state graph — Replace the implicit "next tool call" loop with a defined state machine where each turn is a state transition
  2. Persistent working state — Let agents maintain structured state (variables, intermediate results) that survive context compaction
  3. Branching & merging — Support parallel sub-agent branches that merge results back into the main graph
  4. Checkpointing — Save agent state so long-running tasks can pause and resume without losing progress
  5. Human-in-the-loop nodes — Formalize the "request plan review" / "ask for confirmation" patterns as explicit graph nodes
  6. Conditional routing — Route to different agent types or tools based on current state rather than a flat delegation decision tree

Why this matters

  • Long-running agent sessions lose context quality as compaction kicks in
  • Multi-step plans currently rely on the orchestrator remembering steps across turns
  • No way to pause a complex agent run and resume later with full context
  • Debugging agent behavior is hard without explicit state transitions to trace

Related

  • Current context compaction issues observed in long agent sessions
  • Cross-chat context hacks suggest the system is already reaching for better state management

Activity

  1. self-assigned this
    on Jun 28, 2026
  2. 101 remaining items

  3. moved this from Done to In progress in Team Openhumanon Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions