Skip to content

fix: harden amphibious template hooks & realign skills with new scaffold#194

Merged
lynnlink merged 6 commits into
devfrom
fix/skills-and-amphibious-fallback
Apr 29, 2026
Merged

fix: harden amphibious template hooks & realign skills with new scaffold#194
lynnlink merged 6 commits into
devfrom
fix/skills-and-amphibious-fallback

Conversation

@lynnlink

Copy link
Copy Markdown
Contributor

Summary

This branch bundles two related streams of work that landed under
fix/skills-and-amphibious-fallback:

  1. Amphibious robustness — make the framework tolerate two classes of
    user-code shape that previously crashed it.
  2. Skills + scaffold realignment — collapse the scaffold to a single
    amphi.py and update the bridgic-amphibious skill docs to match.

A new CI gate is also added so PRs to main cannot ship with a broken
skills install-deps step.

Amphibious robustness

  • on_workflow helper exceptions (anything raised between yields) are
    now caught and routed:
    • WORKFLOW mode → original exception is re-raised as-is.
    • AMPHIFLOW mode → execution falls back to on_agent(ctx).
    • Forced AMPHIFLOW without an on_agent override → clear RuntimeError.
  • AI-generated stub overrides no longer break the framework:
    • Worker-level before_action / after_action returning None is
      treated identically to _DELEGATE (delegate to the agent-level hook).
    • Agent-level before_action returning None is treated as passthrough
      (the original decision_result is preserved).
    • async def on_workflow(...): pass (a coroutine, not an async
      generator) is now recognized as not overridden via
      inspect.isasyncgenfunction, so RunMode.AUTO falls back to the
      agent path instead of crashing on the generator protocol.

Skills & scaffold

  • scaffold.py simplified to emit a single amphi.py with an
    architecture stub.
  • skills/bridgic-amphibious/SKILL.md and the architecture /
    api-reference documents updated to match the new scaffold and the
    helper-error semantics above.
  • New top-level skills/README.md.

CI

  • New workflow .github/workflows/skill-install-deps-check.yml that
    gates PRs targeting main on a successful skills install-deps run.

Test plan

  • uv run pytest -q (97 passed, including 8 new stub-override
    tests in tests/test_stub_override_robustness.py and 3 helper-error
    tests in tests/test_workflow_helper_error.py)
  • CI: skill-install-deps-check runs green against this branch
  • Spot-check that a freshly scaffolded project (amphi init) still
    runs end-to-end against the updated amphi.py template

lynnlink added 6 commits April 18, 2026 11:15
- Add .github/workflows/skill-install-deps-check.yml that discovers
  each skills/*/scripts/deps*.ini dynamically and, per config, runs
  install-deps.sh in a fresh mktemp -d, asserting the DEPS_READY
  marker. A policy-guard step rejects any section whose source is
  not "default", so only public-PyPI references can reach main.
- Rewrite skills/README.md as the top-level index for the skills
  system: skill list, directory layout, installer usage, deps.ini
  grammar, and the CI gate convention.
Helper code or inline logic between yields in on_workflow() previously
crashed the entire run because the inner try only caught StopAsyncIteration.
The generator is unrecoverable after a raise (asend would fail), so the
fix mirrors full-fallback semantics: WORKFLOW mode re-raises; AMPHIFLOW
mode hands off to on_agent(ctx); AMPHIFLOW without an on_agent override
surfaces a clear RuntimeError tagged with the failing step index.
Replace the multi-file project layout (task.md, config.py, tools.py,
workers.py, agents.py + skills/result/log dirs) with a single amphi.py
emitted directly into the target directory. Runtime concerns (.env,
__main__) are out of scope for the scaffold.

The new template surfaces the framework's main building blocks —
custom CognitiveContext, AmphibiousAutoma subclass, think_unit,
CognitiveWorker, and both on_agent / on_workflow stubs — so a user
discovers the architecture by reading the file rather than from
external docstrings.

CLI: drop required -n/--name; bridgic-amphibious create now writes
./amphi.py (or under --base-dir). --task is injected as a top-level
"# Task: ..." comment when provided.
…or semantics

Update SKILL.md and references to match recent code changes:

- Scaffold CLI no longer takes -n/--name; only emits a single amphi.py
  in the target directory. Update CLI examples, flag table, and the
  Generated structure block accordingly. Add a brief note on the
  Python API signature.
- Workflow Fallback Mechanism now distinguishes ActionCall tool
  failures (existing step-level fallback path) from generator-internal
  exceptions (helper / inline logic raises), which are unrecoverable
  and route to full on_agent fallback (or re-raise in pure WORKFLOW).
Empty `pass`-body overrides of `before_action` / `after_action` /
`on_workflow` no longer break the framework:

- worker `before_action` / `after_action` returning `None` is treated
  identically to `_DELEGATE` so the agent-level hook still runs
- agent `before_action` returning `None` is treated as passthrough,
  preserving the original `decision_result`
- `_has_workflow()` now requires `inspect.isasyncgenfunction`, so a
  coroutine-body `on_workflow: pass` is recognized as "not overridden"
  and `RunMode.AUTO` falls back to the agent path instead of crashing
  on the async-generator protocol
Extends the previous stub-override compatibility pass to two more
hooks where an AI-generated `pass` body would silently corrupt
behavior (rather than crash loudly):

- `CognitiveWorker.observation` returning `None` is now treated
  identically to `_DELEGATE`, so the agent-level observation
  fallback still runs instead of `None` being written into
  `ctx.observation`.
- `AmphibiousAutoma.action_custom_output` returning `None` is now
  treated as passthrough, preserving the original `decision_result`
  so a typed `output_schema` value is not silently dropped.

Two new tests cover the canonical AI-generated `pass` shape for
each hook.
@lynnlink lynnlink merged commit a75867e into dev Apr 29, 2026
48 checks passed
@lynnlink lynnlink deleted the fix/skills-and-amphibious-fallback branch April 29, 2026 06:03
@lynnlink lynnlink mentioned this pull request Apr 29, 2026
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.

3 participants