Skip to content

Retarget persistent runtime to Codex app-server#91

Open
jeremyplichta wants to merge 3 commits into
mainfrom
codex/issue-83-persistent-agent-runtime
Open

Retarget persistent runtime to Codex app-server#91
jeremyplichta wants to merge 3 commits into
mainfrom
codex/issue-83-persistent-agent-runtime

Conversation

@jeremyplichta
Copy link
Copy Markdown
Collaborator

@jeremyplichta jeremyplichta commented Apr 23, 2026

Summary

  • retarget the persistent tt agent-loop runtime to codex app-server instead of the earlier Claude-first streaming adapter
  • keep persistent mode Codex-first (codex, codex-mini) and fall unsupported CLIs back to the existing one-shot loop
  • map Codex JSON-RPC thread/turn lifecycle into Tinytown runtime events, session persistence, urgent mid-turn steering, and interrupt handling
  • replace the Claude-specific fake streaming harness with a fake Codex app-server and refresh the focused persistent-runtime integration coverage

Testing

  • cargo test --no-run
  • target/debug/deps/integration_tests-9ee69f1b1d41bbad test_agent_loop_persistent_runtime_ --nocapture
  • cargo test --test integration_tests test_agent_persistent_config_parse -- --nocapture
  • cargo test --test integration_tests test_persistent_agent_loop_exits_cleanly_after_idle_timeout -- --nocapture

Closes #83.


Note

Medium Risk
Introduces a new persistent subprocess execution path for tt agent-loop (including interruption/restart behavior) and stores new state in Redis, which could affect worker reliability and message handling if edge cases are missed.

Overview
Adds an opt-in persistent streaming runtime for tt agent-loop ([agent].persistent = true) that keeps a long-lived coding CLI session across turns (currently implemented for codex/codex-mini via codex app-server), while preserving the existing one-shot subprocess-per-turn default.

Agent state now persists a runtime_session_id in Redis to resume streaming sessions after restarts, and the persistent loop is driven by structured runtime events (turn started/completed, tool calls, deltas, awaiting input, runtime errors) which are also emitted onto the per-agent Redis event stream. Documentation is updated to describe the runtime model, and integration tests add coverage for persistent reuse, urgent mid-turn injection, stop interruption, idle-timeout behavior, and event emission.

Reviewed by Cursor Bugbot for commit ba5dd39. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread src/agent_runtime.rs
Comment thread src/agent_runtime.rs Outdated
Comment thread src/main.rs
@jeremyplichta jeremyplichta changed the title Add persistent streaming agent runtime Retarget persistent runtime to Codex app-server Apr 23, 2026
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ba5dd39. Configure here.

Comment thread src/main.rs
}
}
section
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Persistent backlog section missing overflow and guard notices

Medium Severity

The persistent loop's backlog_section is missing two pieces of logic present in the one-shot version: the overflow notice when total_matching > tasks.len() ("...and X more role-matching backlog task(s)") and the guard message when total_backlog > 0 but no tasks match the role ("No backlog tasks currently match your role hint. Do not claim unrelated work by default."). Without the guard message, persistent-mode agents may claim unrelated backlog tasks.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ba5dd39. Configure here.

Comment thread src/main.rs
5. Use `supervisor` / `conductor` when you need human guidance, priority changes, broader sequencing, escalation, or town-wide visibility.
6. If blocked, send a query with specific unblock needs.
7. Use `tt task current` to confirm the real Tinytown task id before completing work.
8. When finished with a task, mark it complete: `tt task complete <task_id> --result \"what was done\"`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raw string literal contains spurious backslash-escaped quotes

Low Severity

Line 878 uses \"what was done\" inside a r#"..."# raw string literal. In raw strings, backslashes are not escape characters, so the output contains literal \" characters. The one-shot prompt correctly uses unescaped "what was done". The persistent agent sees garbled instructions with stray backslashes.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ba5dd39. Configure here.

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.

Persistent coding-agent processes with streaming I/O (replace per-round cold spawns)

1 participant