Skip to content

Commit 16d5e02

Browse files
committed
Replacing agent-loop with a proper fsm.
1 parent c990c99 commit 16d5e02

3 files changed

Lines changed: 530 additions & 139 deletions

File tree

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ A Python port of the Emacs [gptel-agent-harness](https://github.com/beacoder/gpt
44

55
## Features
66

7-
- **Agent loop with completion supervision** — the model is nudged (max 2) when it
8-
tries to stop before the task is complete; the nudge counter resets on tool
9-
calls; tool results are sanitized so a failed call never strands the loop.
7+
- **FSM-driven agent execution with completion supervision** — the run is
8+
driven by a finite state machine (WAIT/TOOL/TRET/SUPERVISE/DONE/ERRS/
9+
ABRT); the model is nudged (max 2) when it tries to stop before the task
10+
is complete; the nudge counter resets on tool calls; tool results are
11+
sanitized so a failed call never strands the machine.
1012
- **API retry with backoff** — transient failures (HTTP 429 / 5xx, connection
1113
errors) are retried automatically with exponential backoff + jitter
1214
(honoring `Retry-After`), so a rate limit or a dropped connection no longer
@@ -37,7 +39,7 @@ A Python port of the Emacs [gptel-agent-harness](https://github.com/beacoder/gpt
3739
prompt; sub-agents in plan mode receive the read-only reminder.
3840
- **Sessions** — auto-saved after every response to
3941
`~/.local/share/python-agent-harness/sessions/`, LLM-generated titles
40-
(one-shot per session, fired when the agent loop finishes; the file is
42+
(one-shot per session, fired when the agent run finishes; the file is
4143
renamed to `<title>_<TS>.md`), `/restore` (with `--latest`) and
4244
`/sessions` TUI commands.
4345
- **Commands**`/init` (create/update AGENTS.md), `/review` (uncommitted
@@ -152,7 +154,7 @@ clobber the next run's state (per-run cancellation identity).
152154

153155
```
154156
python_agent_harness/
155-
├── agent.py agent loop (supervision, nudges, compaction)
157+
├── agent.py agent FSM (states, transitions, supervision, compaction)
156158
├── client.py OpenAI-compatible streaming client (httpx)
157159
├── models.py Message / ToolCall / ToolSpec data classes
158160
├── token_estimator.py CJK-aware token estimation + calibration
@@ -184,5 +186,5 @@ Python ≥ 3.11 is required (CI runs 3.11 / 3.12 / 3.13).
184186
- [x] Plan mode: read-only + plan-file writes only
185187
- [x] Bash: Ctrl-C process-group kill
186188
- [x] Session metadata round-trip and title sanitization
187-
- [x] One-shot LLM title generation after the agent loop finishes
189+
- [x] One-shot LLM title generation after the agent run finishes
188190
- [x] Ctrl-C cancel: stale workers can't clobber the next run's history

0 commit comments

Comments
 (0)