Allow `Coder` and `Researcher` to load from agent specs

Draft
EL
3d ago
+36-0

Why we make these changes

Coder and Researcher inherit CombinedCapability but do not have their own dataclass marker. The custom-capability registry therefore rejects them before loading an agent spec.

Decorate both classes with @dataclass(init=False, repr=False, eq=False) so the registry accepts them without replacing their handwritten constructors or inherited representation/equality methods. Add public Agent.from_spec regression tests for default construction and non-default sub_agents/instructions options.

New public surface

None.

User-visible behavior

Agent.from_spec({'model': 'test', 'capabilities': ['Coder']}, custom_capability_types=[Coder]) now constructs an agent instead of raising the dataclass ValueError. The same applies to Researcher.

Verification

Original validation on Python 3.12.14 at dbb7dc6:

  • All four added tests fail with the reported dataclass error against the unmodified upstream source.
  • 201 selected tests pass after the fix, covering capability specs and local Coder/Researcher behavior.
  • Repository-wide Ruff format/check pass; targeted Pyright reports zero errors.
  • Harness source distribution and wheel build successfully (shallow checkout version metadata, not release artifacts).
  • Before/after constructor, repr and equality method signatures, defining names and bytecode fingerprints match.

One existing Researcher integration test did not pass in this environment: resolving docs.python.org failed, producing a snapshot mismatch and a teardown error. The final 201-test selection excludes that test; no snapshots were changed. The complete repository suite and Coder Temporal/server-backed engine tests were not run.

After refreshing the same patch onto 51b883a, 270 focused tests pass (1 skipped), including the upstream strict-schema tests. Ruff format/check and targeted Pyright pass against the refreshed workspace sources.

What changes for existing users

Spec loading accepts Coder and Researcher; their existing constructors, representation and equality methods remain unchanged.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it. (Not applicable: no compatibility impact.)
  • PR title is fit for the release changelog.