spec: skills may call a plain HTTP API directly; bridges are opt-in
Reframe bridges as a deliberate choice rather than the mandatory path to any third-party system. A skill body may call a service's own HTTP API directly with a stdlib transport; a bridge is warranted only when a simple, repeatable skill file would be inconsistent, inconvenient, or unsafe — state (especially auth state), sanitized connectivity, or a native/heavy protocol. When a bridge fronts a service, the body calls the bridge and must never reach around it. Updates CODEGEN.md, PACKGEN.md, TESTGEN.md, README.md, AGENTS.md, the bridges/__init__.py docstring, the codegen BODY_DIRECTIVES + describe_ bridges() prompt strings, and the tests pinning their wording.
This commit is contained in:
1 parent
f379c0a746
commit
0b02a3feac
10 files changed
+122
-59
No files matched your search
+55
-19
@@ -13,7 +13,12 @@ contract `PACKGEN.md`.
|
||||
## What a skill is
|
||||
|
||||
Semif-agent is an end-user application: an everyday person asks it to do a task,
|
||||
and it does that task using a combination of native python modules, user-provided data and a catalog of basic services known as bridges. A skill is the thing that performs one of those tasks: it is the leaf in the skill tree that the agent navigates to when it has resolved a request to a single, concrete action. Navigation is performed by an llm-based decision engine known as SemIf.
|
||||
and it does that task using native python modules — including direct HTTP
|
||||
requests to a service's own API — user-provided data, and, where warranted, a
|
||||
catalog of basic services known as bridges. A skill is the thing that performs
|
||||
one of those tasks: it is the leaf in the skill tree that the agent navigates to
|
||||
when it has resolved a request to a single, concrete action. Navigation is
|
||||
performed by an llm-based decision engine known as SemIf.
|
||||
|
||||
A skill is three things:
|
||||
|
||||
@@ -180,6 +185,14 @@ Rules:
|
||||
hand; a title is generated by the LLM, not assembled by string concatenation
|
||||
when it should be written; a date is parsed by code, not asked of a model.
|
||||
|
||||
**Connectivity is separate from these three sources.** The table is about
|
||||
*values*, not about how a body reaches a service. A body calls a **plain HTTP
|
||||
API directly** with a stdlib transport (endpoint and credentials read from
|
||||
`ctx.config`); a bridge is only for a service that needs state (especially auth
|
||||
state), a native or heavy protocol, or one sanitized surface. See "Bridge
|
||||
services" below for when to use one — and the hard rule for a service a bridge
|
||||
already fronts.
|
||||
|
||||
## The registry entry
|
||||
|
||||
The body writer does **not** author a manifest. The `llm` provider authors the
|
||||
@@ -557,29 +570,44 @@ therefore run as a later step of a chain.
|
||||
- **Keep the body small — it is ingested whole.** The fidelity decision reads
|
||||
the *entire* body, so a body that exceeds the engine's context budget is
|
||||
rejected outright (the pipeline retries once with a "make it shorter"
|
||||
instruction). Delegate protocol details to a bridge instead of hand-rolling a
|
||||
client, and keep `act` to one purpose; a long body is a signal that the
|
||||
integration belongs in a bridge.
|
||||
instruction). Delegate **complex** protocol details to a bridge instead of
|
||||
hand-rolling a client (a simple HTTP call needs no bridge), and keep `act` to
|
||||
one purpose; a long body is a signal that the integration belongs in a bridge.
|
||||
- **The function is `act` exactly.** The module is imported under its registered
|
||||
leaf name; the entry point is a module-level `act(ctx, request)`.
|
||||
|
||||
## Bridge services
|
||||
|
||||
Some real systems are reached through a **bridge service**: a standalone local
|
||||
process that stands up a small, token-guarded HTTP API in front of the system
|
||||
and owns its native protocol and credentials. The concrete catalog of bridges —
|
||||
which services exist, their base-URL config var, auth, config vars, and the
|
||||
exact endpoints with their request/response/error shapes — is injected into the
|
||||
prompt at authoring time (render it with
|
||||
A body reaches a real service with a stdlib transport. A **plain HTTP API** is
|
||||
called directly — `urllib.request` / `http.client`, endpoint and credentials read
|
||||
from `ctx.config` — and needs no bridge. Some systems, however, are reached
|
||||
through a **bridge service**: a standalone local process that stands up a small,
|
||||
token-guarded HTTP API in front of the system and owns its native protocol,
|
||||
credentials, and connection state. Reach for a bridge only when a simple,
|
||||
repeatable skill file would otherwise be inconsistent, inconvenient, or unsafe:
|
||||
|
||||
- **State, especially auth state.** The service needs an OAuth token, a session
|
||||
cookie, a live daemon connection, a read cursor, or other state a stateless,
|
||||
re-run-from-the-top `act` cannot own.
|
||||
- **Sanitized connectivity.** You want one narrow, token-guarded, audited
|
||||
surface instead of arbitrary bodies speaking the service's raw protocol.
|
||||
- **A native or heavy protocol.** The service speaks WebSocket/DAV/OCS or needs
|
||||
a third-party dependency (a browser, a mail client) a one-file stdlib body
|
||||
must not carry.
|
||||
|
||||
When a bridge **does** front a service, the body calls the bridge and must never
|
||||
reach around it to the service's native protocol — no WebSocket to
|
||||
`simplex-chat`, no direct daemon access, no DAV/OCS hand-rolling. It calls the
|
||||
bridge's HTTP API with the base URL from the bridge's config variable, exactly
|
||||
like any other HTTP integration:
|
||||
|
||||
The concrete catalog of bridges — which services exist, their base-URL config
|
||||
var, auth, config vars, and the exact endpoints with their request/response/error
|
||||
shapes — is injected into the prompt at authoring time (render it with
|
||||
`semif_agent.bridges.describe_bridges()`); read it rather than guessing. This
|
||||
section is only the generic pattern; the catalog is the source of truth for the
|
||||
bridge-specific details.
|
||||
|
||||
A body must never speak a service's native protocol directly — no WebSocket to
|
||||
`simplex-chat`, no direct daemon access. It calls the bridge's HTTP API with the
|
||||
base URL from the bridge's config variable, exactly like any other HTTP
|
||||
integration:
|
||||
|
||||
```python
|
||||
INTEGRATION = {
|
||||
"service": "<the bridge's service id, from the catalog>",
|
||||
@@ -590,6 +618,9 @@ INTEGRATION = {
|
||||
|
||||
Rules:
|
||||
|
||||
- **A plain HTTP service needs no bridge.** If the service exposes a normal HTTP
|
||||
API and needs none of the three triggers above, call it directly with a stdlib
|
||||
transport; declare its endpoint in `CONTRACT` and read it from `ctx.config`.
|
||||
- **Read every value from `ctx.config`.** The base URL, any token, and any
|
||||
default (recipient/contact/target) come from the config vars the catalog
|
||||
lists. Never hardcode a host, port, or bridge address in the body.
|
||||
@@ -617,6 +648,9 @@ Rules:
|
||||
|
||||
- Single purpose, single file, single module.
|
||||
- Avoid duplicating an existing skill in the same category.
|
||||
- Reach a plain HTTP API directly; use a bridge only for a service that needs
|
||||
state/auth, a native or heavy protocol, or one sanitized surface — and never
|
||||
reach around a bridge that fronts the service.
|
||||
- `act` resolves ambiguity (arguments, recipients, targets) with SemIf
|
||||
sub-decisions, mirroring how `nextcloud.create_event` resolves which calendar
|
||||
to write to.
|
||||
@@ -658,12 +692,14 @@ A generated skill is accepted only if:
|
||||
11. `INTEGRATION` is present, flat, string-valued, uses the transport vocabulary,
|
||||
and is consistent with the body's `ctx.config` reads and behavior.
|
||||
12. It does no network, file, or engine work at import time.
|
||||
13. If it is a messaging skill, it uses a bridge service over HTTP (never a
|
||||
service's native protocol), resolves recipients with a SemIf sub-decision,
|
||||
and sends only on explicit user intent.
|
||||
13. If the service it targets is fronted by a bridge, it calls that bridge over
|
||||
HTTP (never the service's native protocol); otherwise it may call the
|
||||
service's HTTP API directly. A messaging skill resolves recipients with a
|
||||
SemIf sub-decision and sends only on explicit user intent.
|
||||
14. It is small enough to be ingested whole by the fidelity decision (a body
|
||||
over the engine's artifact budget is rejected as too long) — delegate
|
||||
protocol details to a bridge rather than hand-rolling them.
|
||||
complex protocol details to a bridge rather than hand-rolling them (a simple
|
||||
HTTP call needs no bridge).
|
||||
|
||||
Items 1 and 7 are hard checks in the parser (`parse_skill_body`) and reject the
|
||||
body outright. The rest are not statically rejected: a missing or inconsistent
|
||||
|
||||
Reference in new issue
Block a user