Skip to content

fix(agent): unify goal activation and harden long-running execution - #3211

Merged
bobleer merged 7 commits into
GCWing:mainfrom
bobleer:bob/fix-cross-surface-goal-prompts
Sep 23, 2026
Merged

bobleer merged 7 commits into
GCWing:mainfrom
bobleer:bob/fix-cross-surface-goal-prompts

Conversation

@bobleer

@bobleer bobleer commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Plain /goal <objective> messages now activate the persistent goal on the executing host, including mobile/IM relay, peer-host and CLI submissions. Previously the Web UI intercepted the command while other clients sent an ordinary message, and the runtime excluded that prompt from goal accounting and continuation.

The lifecycle audit also found that headless jobs could report success after the first turn, sessions shared one accounting state, and budget wrap-up could repeat. This PR fixes those behaviors and aligns first-turn, edited-objective and continuation prompts around the same evidence-based completion contract.

Behavior

  • Activate objectives in shared turn admission, steering and promoted host-queue messages without a second submission. Preserve attachments, remote workspace identity and authoritative session storage. Validate replacements before writing; retrying the same active objective preserves usage.
  • Route /goal through CLI startup, chat, steering and the action registry; keep existing control words reserved.
  • Isolate usage by session, serialize goal mutations, record goal usage synchronously at the model producer (rather than through a lagging event subscriber), settle usage before terminal status changes, and reject stale-turn status updates. Updated-objective work also participates in accounting.
  • Run one budget wrap-up, preserve usage when resuming a blocked goal, and reset its continuation window. Plain goal prompts still have no token budget by default.
  • Keep exec and Detached Dispatch observing matching goal continuations. An intermediate successful turn does not finish the job; incomplete stopped goals return errors. Persist the dispatch job's current continuation turn and keep CLI cancellation targeted to the observed turn.
  • Submit continuation retries independently of the global outcome handler. Fence retries and queued continuations by current goal identity, objective, status and attempt; retire obsolete internal work rather than holding the user's queue. Surface scheduling/persistence failures.
  • Share lifecycle instructions across initial/edited and continuation prompts: preserve subsequent user requirements, recover context from current evidence, avoid duplicate external mutations, and verify every requested deliverable before completion. Template expansion preserves literal placeholders in user objectives.

No wire fields, persisted shapes, Cargo features or model settings change. Old hosts retain their old behavior; upgrading a controller cannot upgrade a target's goal implementation.

Verification

AI-assisted implementation and full-flow review. Focused local checks:

  • cargo test --locked -p openbitfun-agent-runtime --no-default-features --features agent-runtime --test agent_long_horizon_contracts
  • cargo test --locked -p openbitfun-agent-runtime --no-default-features --features agent-runtime --test agent_session_contracts scheduler_contracts::
  • cargo test --locked -p openbitfun-core --no-default-features --features agent-runtime,git,remote-workspace --lib -- thread_goal_ host_queue_ agentic::goal_mode:: agentic::execution::round_executor::tests
  • cargo test --locked -p openbitfun-cli --bin openbitfun -- modes::exec::tests:: dispatch::worker::tests:: dispatch::store::tests::goal_continuation_ actions:: modes::chat::tests::goal_prompts_ modes::chat::tests::pending_session_operation ui::command_menu:: ui::command_palette::
  • cargo check --locked -p openbitfun-desktop, cargo build --locked -p openbitfun-desktop, and cargo test --locked -p openbitfun-desktop --lib (468 passed, 11 ignored)
  • pnpm run fmt:rs, pnpm run check:repo-hygiene, and git diff --check

Coverage includes parser boundaries, legacy metadata, remote storage identity, repeated steering, duplicate queue promotion, concurrent usage reads, terminal and failed-turn accounting, stale mutations/retries/queues, budget wrap-up, blocked resume, headless goal-run transitions, prompt escaping, dispatch continuation-turn persistence and stale-owner rejection, and existing CLI output/settlement/dispatch contracts. A scheduler regression also exercises an unrelated session completing while a goal continuation is retrying.

Remote workspace identity/storage and host-owned queue execution are exercised with fixtures. Physical mobile relay, IM, SSH and Peer Device sessions, real-provider multi-turn execution and a disconnected remote Detached Dispatch run have not been exercised end to end. Headless continuation decisions and existing worker/exec projection paths have focused tests; this is not a claim of real-provider task completion.

Windows CI hit the existing narrowly tolerated Tauri desktop test loader failure (0xc0000139 / STATUS_ENTRYPOINT_NOT_FOUND) before tests executed. Windows desktop library tests therefore did not run; Windows compilation, Core, CLI and other contract checks passed. Linux CI and local macOS desktop library tests passed. This PR does not change that CI exception.

Remaining boundaries

The existing 100-continuation safety stop remains; explicit resume resets that window. Optional token accounting covers main-session non-cached input plus output, not provider-wide or child-session billing, and is a soft limit. Host restart recovery still requires explicit session inspection/resumption. Prompt instructions strengthen completion auditing but cannot prove arbitrary user objectives independently of model judgment. These limits are documented in the CLI README.

Checklist

  • Changes stay with shared runtime policy, current Core lifecycle owners and surface adapters.
  • No secrets, generated artifacts or unrelated work.
  • Verification scope, remote coverage and remaining limitations are recorded.

@bobleer
bobleer marked this pull request as ready for review September 23, 2026 06:31
@bobleer bobleer changed the title fix(agent): activate goal prompts across sending surfaces fix(agent): unify goal activation and harden long-running execution Sep 23, 2026
@bobleer
bobleer merged commit c4396f6 into GCWing:main Sep 23, 2026
13 checks passed
@bobleer
bobleer deleted the bob/fix-cross-surface-goal-prompts branch September 24, 2026 08:19
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