Skip to content

Agent loop + resilience hardening (Phase 7–8) - #10

Merged
bethvourc merged 6 commits into
mainfrom
desktop-macos
Jun 23, 2026
Merged

bethvourc merged 6 commits into
mainfrom
desktop-macos

Conversation

@bethvourc

Copy link
Copy Markdown
Owner

Summary

Five commits on top of the last desktop-macos merge (#9): resilience/security hardening for the gateway and the new deliberate agent loop.

  • a38bd29 — PortInUseError: the daemon refuses to silently port-hop, logs gateway.port_in_use, and exits cleanly (code 2) instead of dumping a raw OSError.
  • 8bcca9b — large (10k-item) activity feed generation + ResilienceUITests (overlay/menu recovery destinations + scroll perf).
  • 31e9a35 — macOS app support & configuration management (pins shipped daemon state under Application Support).
  • 477ba4e — deny-by-default authorization tests for GatewayService (locks AUTH_EXEMPT_PATHS; every other route must reject missing/wrong tokens).
  • 2a0d967 — deliberate agent loop (detail below).

Highlight: deliberate agent loop

Upgrades the agent's flat ReAct loop into a two-level loop so Iris can tackle complex multi-step requests and recover when it gets stuck:

  • Plan-aware planner — the first planning turn can return a {"type":"plan","subgoals":[…]} shape, so the model judges complexity (no lexical heuristic, no separate decomposition call). A simple request's triage turn is seeded as its first step, keeping it to one planner call.
  • Sub-goal orchestration — _triage_plan / _invoke_planner / _run_subgoal / _finalize, bounded by per-sub-goal and global step budgets.
  • Stuck detection + escalate-then-ask-early — repeated-action / no-progress detection injects a _stuck_signal to push a different approach, then stops with a "blocked" message (resumable background-task status) once escalations run out.
  • New pure-logic module src/iris/agent_loop.py + tests/test_agent_loop.py.

Surface is the deep + background paths only; live Realtime voice stays a single-tool shim to protect barge-in latency. Backward compatible — single-sub-goal runs behave as before, plus graceful stuck exits.

Testing

  • uv run pytest — 278 passed
  • uv run ruff check . / ruff format — clean

Notes

  • main has since merged a couple of unrelated PRs (CLI error messages, live-interruptions) not on this branch — it shows as diverged (behind by 5). Flag any merge conflict in cli.py (both touched CLI error paths).
  • Planning notes live in implementation/desktop-macos-plan.md (gitignored, local only).

🤖 Generated with Claude Code

bethvourc and others added 6 commits June 19, 2026 09:16
- Introduced a new PortInUseError class to handle port conflicts more gracefully.
- Updated cmd_serve to catch PortInUseError and return a specific exit code for port conflicts.
- Enhanced GatewayService to raise PortInUseError when the configured port is already in use, improving error clarity.
- Added a regression test to ensure that attempting to serve on an occupied port raises the new exception and logs the appropriate error message.
- Introduced a new case in ScriptedActivityService to handle a large activity feed with ~10,000 items for resilience auditing.
- Added a static method to generate synthetic JSON data for testing purposes.
- Updated project configuration to include ResilienceUITests, which automates UI testing for the new large activity feed.
- Enhanced documentation to reflect the automation of UI tests for resilience scenarios, ensuring smooth scrolling and performance verification.
- Added a new section in README.md detailing the native macOS app features, including menu-bar presence, voice overlay, and activity management.
- Updated AppModel to ensure the state database is pinned under Application Support for shipped apps, preventing reliance on the process current working directory.
- Enhanced DaemonConfiguration to include a stateDatabaseURL parameter, ensuring proper environment variable setup for the state database.
- Added unit tests to verify that the state database environment variable is correctly set for bundled configurations, improving reliability in deployment.
- Introduced new tests to validate authorization behavior for protected and exempt routes in GatewayService.
- Defined _PROTECTED_ROUTES and _EXEMPT_ROUTES to establish a clear source of truth for route authorization.
- Added assertions to ensure that protected routes deny access by default and that exempt routes are accessible without a token.
- Implemented a test to catch accidental exemptions of protected routes, enhancing security and review processes.
Upgrade the agent's flat ReAct loop into a two-level loop so Iris can
tackle complex multi-step requests and recover when it gets stuck.

- Plan-aware planner: the first planning turn can return a {"type":"plan",
  "subgoals":[...]} shape, so the model judges complexity with no separate
  decomposition call and no lexical heuristic. A simple request's triage
  turn is seeded as the first step, keeping it to one planner call.
- Sub-goal orchestration in AgentExecutor.run() (_triage_plan /
  _invoke_planner / _run_subgoal / _finalize), bounded by per-sub-goal and
  global step budgets.
- Stuck detection (repeated action / no visible progress) with an
  escalate-then-ask-early ladder: inject a _stuck_signal to push the
  planner to a different approach, then stop with a "blocked" message
  (maps to the resumable background task status) once escalations run out.
- New pure-logic module agent_loop.py (Plan/SubGoal, coerce_subgoals,
  normalize_call, observation_signature, detect_stuck) + 12 tests.

Surface is the deep + background paths only; live Realtime voice stays a
single-tool shim to protect barge-in latency. Backward compatible:
single-sub-goal runs behave as before, plus graceful stuck exits.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bethvourc
bethvourc merged commit f0193b3 into main Jun 23, 2026
3 checks passed
@bethvourc
bethvourc deleted the desktop-macos branch September 22, 2026 14:39
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.

1 participant