Skip to content

rescue: spec extensions + avp-ollama runner package - #10

Open
Patrick Carney (pcarney8) wants to merge 1 commit into
avp-openai-agentfrom
rescue/spec-and-ollama
Open

rescue: spec extensions + avp-ollama runner package#10
Patrick Carney (pcarney8) wants to merge 1 commit into
avp-openai-agentfrom
rescue/spec-and-ollama

Conversation

@pcarney8

Copy link
Copy Markdown

Summary

Stacked on #7 (avp-openai-agent). Additive AVP v0.1 changes + a new minimal-scope runner backing the supervisor-side rescue work in portofcontext#1.

  • Spec (spec/v0.1/trajectory.md §7.2 + §7.3). New event type avp.run_rescued (supervisor-sourced bracket), new error_occurred code execution_backend_failure, new optional avp.runner = {backend, model} per-event attribution field. All additive; existing trajectories remain conformant.
  • Pydantic types. RunRescuedEvent / Data / Endpoint, ErrorCode.execution_backend_failure, discriminated union extended.
  • python/agents/avp-ollama/. New AVP runner backed by local Ollama. Minimal-scope: single chat loop, no tools / MCP / managed assets — intentionally — used to demonstrate rescue without taking on full CASDK feature parity. Honors RESCUE_FAIL_AT (failure injection), OLLAMA_FORCE_TURNS (multi-turn forcing so turn:N fires on a real boundary), AVP_RUNNER_BACKEND (so the same runner code can register under different identities for the rescue demo's primary/secondary pair).
  • Rescue-continuation behavior. On startup the runner queries next_seq from the supervisor — if events already exist, it's a rescued continuation: skip the prelude, start emitting at next_seq, inherit the original agent_started span ids so the span tree stays continuous per §7.3.

Test plan

  • cd python && uv run pytest avp/tests/ -q — 116 passing, no regressions from the additive event type.
  • cd python && uv run pytest agents/avp-ollama/tests/ -q — 11 passing.
  • Pydantic round-trip: RunRescuedEvent(...).model_dump_json(by_alias=True) produces a valid CloudEvents envelope with source: avp://supervisor.
  • End-to-end rescue smoke (driven from protocol-level TODOs from living-testing the two runner SDKs #1's make demo-rescue-local): primary local-ollama fails at turn 2 → supervisor emits avp.run_rescued → secondary local-ollama-2 picks up → agent_stopped(converged).

Out of scope

  • Warm rescue (Commission.resume, deterministic replay) — tracked in portofcontext RESCUE_PLAN.md phase 2.
  • CASDK-equivalent feature parity for avp-ollama — explicitly not the point of this runner; the package README documents the scope.

🤖 Generated with Claude Code

Additive AVP v0.1 changes to support supervisor-orchestrated execution-
backend rescue (see portofcontext rescue/phase-1 PR). All changes
preserve backwards compatibility with existing conformance suites.

Spec (`spec/v0.1/trajectory.md`):
  * New event type `avp.run_rescued` (supervisor-sourced bracket; peer
    event in the trajectory; does not restart the span tree).
  * New `error_occurred.data.avp.error.code` value `execution_backend_failure`
    — runner-side signal that its host environment can no longer continue
    (distinct from agent-internal `agent_crash`).
  * New optional `data.avp.runner = {backend, model}` per-event field
    so consumers can attribute any single event to its producing runner
    after a swap.
  * New §7.2 (per-event attribution) and §7.3 (rescue pattern) — full
    example trajectory included.

Pydantic types:
  * `RunRescuedEvent`, `RunRescuedData`, `RunRescuedEndpoint`
    (`python/avp/src/avp/types.py`) — round-trip verified.
  * `ErrorCode.execution_backend_failure` (`enums.py`).
  * Discriminated `Event` union extended; existing tests pass unchanged.

New runner package `python/agents/avp-ollama/`:
  * Minimal-scope AVP runner backed by local Ollama. Emits a conforming
    AVP trajectory (prelude → multi-turn → cost/stopped) and honors
    `RESCUE_FAIL_AT={now|turn:N|prob:p}` failure injection used by the
    rescue smoke. README documents scope (single chat loop, no tools,
    no managed assets — rescue demo only).
  * `OLLAMA_FORCE_TURNS=N` makes the runner chain `N` turns with a
    synthetic user-continuation between them, so `RESCUE_FAIL_AT=turn:2`
    fires from the realistic "before turn N starts" path rather than
    the short-prompt fall-through.
  * `AVP_RUNNER_BACKEND` env var stamps the correct identity onto
    `avp.runner.backend` in every emitted event — needed when the
    supervisor registers the runner under a non-default identity
    (e.g. `local-ollama-2`).
  * FastAPI dispatch endpoint mirroring `worker/modal_app.py::spawn_endpoint`
    so the supervisor's `LocalOllamaBackend` can drive either backend
    without caring which is on the other end.
  * On startup the runner queries the supervisor's events for the run;
    if events already exist it's a rescued continuation — skip the
    prelude, start at `next_seq`, inherit the original `agent_started`
    span ids so the span tree stays continuous per §7.3.

Workspace plumbing:
  * `python/pyproject.toml` workspace members + sources updated.
  * `python/uv.lock` regenerated.

Stacks on top of the avp-openai-agent PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant