Skip to content

feat: an agent class's instance is a child that answers requests - #726

Merged
tgockel merged 1 commit into
version/0.3.xfrom
0003-34-an-agent-class-answers-requests
Oct 27, 2026
Merged

tgockel merged 1 commit into
version/0.3.xfrom
0003-34-an-agent-class-answers-requests

Conversation

@tgockel

@tgockel tgockel commented Oct 27, 2026

Copy link
Copy Markdown
Owner

A subclass of outrig.Agent declares a long-lived child agent. Its docstring is the first part of the child's instructions, and each async def it marks @outrig.agent is a request channel of that name: the method's docstring describes it, its parameters make the request -- none carries None, one its value, several a frozen dataclass Message the class holds -- and its return annotation is the reply's type. The body is never run or read. Every rule is checked as the class is made, in a module or a submission alike, and a broken one raises TypeError naming the member; @outrig.agent in the body of a class that is not an agent class is refused the same way.

FooAgent(**inputs, model=...) checks its inputs and returns at once, launching a request child in the background. The child's first round opens as it launches, for getting ready, and await foo.ready() waits for it. A method call checks its arguments, sends the request and returns its handle at once. A request made before the child exists is held on the child's record, made with the instance and taken by the child's kernel when it opens, so it counts against requests-max, cancels and ends like any other, and is sent as the spawn answers. What the launch meets -- an unknown model, a limit, the session closing -- raises at ready() and at each request, never in the constructor. release(), async with, the session's close, and a finalizer for an instance collected unreleased each end the child and what it launched; a request in flight holds its instance.

The host tells the interpreter requests-max in a new limits line, and an instance's readiness in an oriented line. Five events record each instance under its child's subject: agent.instance.started, .ready, .released, .collected and .handle.collected. Payload gains their variants, with AgentInstanceId and InstanceRelease.

Summary

What does this change, and why?

Checklist

  • cargo fmt --all -- --check passes
  • cargo clippy --workspace --all-targets -- -D warnings is clean
  • cargo test --workspace passes
  • Docs in doc/ updated if behavior changed (mdbook build still clean)
  • CHANGELOG updated for user-visible changes

Notes for reviewers

Anything worth calling out -- tricky bits, follow-ups, or intentionally out-of-scope items.

@tgockel
tgockel force-pushed the 0003-34-an-agent-class-answers-requests branch from 8c57d71 to ab07ef2 Compare October 27, 2026 19:24
A subclass of outrig.Agent declares a long-lived child agent. Its
docstring is the first part of the child's instructions, and each
async def it marks @outrig.agent is a request channel of that name:
the method's docstring describes it, its parameters make the request
-- none carries None, one its value, several a frozen dataclass
<Class><Method>Message the class holds -- and its return annotation is
the reply's type. The body is never run or read. Every rule is checked
as the class is made, in a module or a submission alike, and a broken
one raises TypeError naming the member; @outrig.agent in the body of a
class that is not an agent class, or under staticmethod or
classmethod, is refused the same way.

FooAgent(**inputs, model=...) checks its inputs and returns at once,
launching a request child in the background. The child's first round
opens as it launches, for getting ready, and await foo.ready() waits
for it. A method call checks its arguments, sends the request and
returns its handle at once. A request made before the child exists is
held on the child's record, made with the instance and taken by the
child's kernel when it opens, so it counts against requests-max,
cancels and ends like any other, and is sent as the spawn answers.
What the launch meets -- an unknown model, a limit, the session
closing, a child that cannot be built after its kernel opened --
raises at ready() and at each request, never in the constructor.
release(), async with, the session's close, and a finalizer for an
instance collected unreleased each end the child and what it
launched; a request in flight holds its instance. An instance a
child's code made ends with that child, and lets the child's
namespace, which holds it, be freed.

The host tells the interpreter requests-max in a new limits line, and
an instance's readiness in an oriented line. Five events record each
instance under its child's subject: agent.instance.started, with a
digest of the source that declared the class, .ready, .released,
.collected and .handle.collected. Payload gains their variants, with
AgentInstanceId and InstanceRelease.
@tgockel
tgockel force-pushed the 0003-34-an-agent-class-answers-requests branch from ab07ef2 to 8fb6eac Compare October 27, 2026 20:07
@tgockel
tgockel merged commit 8fb6eac into version/0.3.x Oct 27, 2026
9 of 11 checks passed
@tgockel
tgockel deleted the 0003-34-an-agent-class-answers-requests branch October 27, 2026 20:32
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