feat(plugins): add context-aware turn controllers and busy-safe commands - #63208
feat(plugins): add context-aware turn controllers and busy-safe commands#632080error0warning wants to merge 3 commits into
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for extracting this as a generic plugin ABI rather than coupling core to a consumer.
Problems
- Busy-safe gateway commands are unreachable in real traffic. The new runner-side branch in
gateway/run.py:9242is behindBasePlatformAdapter.handle_message(): an active session first checks onlyshould_bypass_active_session()and otherwise queues the event (gateway/platforms/base.py:4675-4826). The added test callsrunner._handle_message()directly, so it bypasses that production guard. - The public ABI is undocumented.
website/docs/developer-guide/plugins/index.md:788still publishes the oldregister_commandsignature and has no contract forCommandContext, turn directives, or controller lifecycle behavior.
Suggested changes
- Extend the adapter-level busy routing to recognize and directly dispatch declared safe plugin controls, then add an end-to-end active-adapter regression test.
- Update the plugin developer guide with the new API and surface-specific follow-up semantics.
Automated hermes-sweeper review.
| if _denied is not None: | ||
| return _denied | ||
|
|
||
| # Plugin commands are absent from the built-in registry. Resolve |
There was a problem hiding this comment.
This branch is not reached for an actual busy adapter session: BasePlatformAdapter.handle_message() queues events unless the command is in its static should_bypass_active_session() set (gateway/platforms/base.py:4675-4826). Route declared busy-safe plugin commands through that adapter-level bypass path and add a test entering handle_message() with an active guard.
|
Thanks for extracting this as a generic plugin ABI. I have a second concrete consumer for this work and wanted to suggest a possible convergence with #65188. Concrete consumer: a source-first supervisorI have a working downstream implementation of a prospective
After every completed agent turn, the supervisor audits the ledger and source coverage. It requests another turn while repository-completable requirements remain, pauses on explicit blockers or sustained lack of progress, and completes only after the evidence and coverage gates pass. It also provides This differs from a general long-running goal controller because completion is measured against exact source-document requirements and evidence, rather than only a free-form mission description. It gives this ABI another real consumer without coupling the ABI to either product. Possible convergence with #65188#65188 already establishes useful session-identity plumbing:
Would it make sense to treat #65188 as the identity layer and this PR as the control layer? In that arrangement, this PR would remain responsible for:
I think the two identities should remain explicit in both @dataclass(frozen=True)
class CommandContext:
surface: str
session_id: str
gateway_session_key: str
platform: str
source: Any | None
task_id: str
metadata: Mapping[str, Any]
enqueue_followup: Callable[[str], Awaitable[bool]]
In particular, stable_identity = context.gateway_session_key or context.session_idOne command-dispatch conventionThe current PR and #65188 propose different context-aware handler conventions. One possible reconciliation would be to preserve #65188's def handle_super(
raw_args: str,
*,
command_context: CommandContext,
):
...Internally: call_plugin_command_handler(
handler,
raw_args,
session_id=context.session_id,
gateway_session_key=context.gateway_session_key,
command_context=context,
)This would support a compatible progression: handler(raw_args)
handler(raw_args, *, session_id="", gateway_session_key="")
handler(raw_args, *, command_context=...)It would avoid maintaining both signature-aware keyword forwarding and a separate Production-path considerationsThe current review correctly notes that busy-safe gateway dispatch must happen before I suggest preserving normal slash-command authorization and adding an E2E test that enters through the real adapter path with an active session. A test that calls It would also help to define follow-up semantics explicitly for each surface. In particular, the current TUI context supplies an Proposed initial acceptance casesMy downstream implementation can contribute reduced tests for the following generic contracts:
Cold-start recovery and delayed session wakeup do not need to be part of this PR. Those appear better aligned with #64229 and #65448. ACP parity could likewise be a focused follow-up once the core contract is settled. Would maintainers be open to treating #65188 as the identity foundation and revising or splitting this PR so that it supplies the command capabilities and turn-control layer on top? I would be happy to provide a reduced source-supervisor fixture and production-path regression tests as an external acceptance consumer. I am also willing to implement this convergence if the direction is acceptable. Depending on contributor and maintainer preference, I can provide commits for this branch or submit a focused successor rebased on #65188. The implementation would be limited to the generic command-context, turn-controller, stable-identity, and production busy-routing contracts described above, with the source supervisor remaining an external acceptance consumer. I would preserve attribution to both existing contributions and avoid opening another overlapping ABI proposal. |
Summary
Adds generic plugin ABI needed by standalone long-running controllers, without any Supergoal-specific code:
CommandContext.session_idandenqueue_followupTurnControlContext/TurnDirectivecontrollers with dedupe and monotonic state versionson_session_rotatehook for compression continuityDesign
The core remains product-name-agnostic. A standalone plugin owns state, policy, evidence, and command semantics; Hermes only provides generic lifecycle and queue primitives.
Verification
tests/hermes_cli/test_plugin_turn_control_abi.pytests/gateway/test_plugin_turn_control_abi.pytests/hermes_cli/test_plugins.pymainpy_compileandgit diff --checkpassedNo new model tools or user-facing environment variables are added.