#346
Implement ai.workers: Worker, WorkerProvider and Session
One of two competing drafts for ai.workers. The other is #347.
A worker is one session of a coding-agent CLI (Codex, Claude Code, Pi). In this draft it has the shape of an ai.Model: plain data and a provider.
Worker: the settings and the state (session_id,messages).WorkerProvider:name,executable,env, and thestream()thatai.streamandai.Agent.runcall.Session: direct control (start,send,events,interrupt,close).
worker = workers.Codex(cwd=".")
async with worker.session() as session:
async with agent.run(worker, messages) as run: ...
await session.send(ai.user_message("And the tests?"))Compared with #347
- Core changes less.
ai.streamstill callsmodel.provider.stream(model, ...); the diff outsideai/workersisModel->ModelLikeannotations, oneaclosingblock inapi.py, theContext.modelannotation, and a newmodels/core/model_like.pywith the two protocols.model.py,hooks.pyandai/__init__.pyare as onmain. - Direct control is on a separate
Session, not on the worker. The CLI starts on first use insideasync with worker.session(), and a model call outside that block raises. - Not here, and in #347: approvals through hooks,
output_type,fork()andsync().
Status
- Offline tests, ruff, mypy (
src tests) and ty pass locally. - The live tests (
AI_WORKERS_LIVE=1 uv run pytest tests/workers/test_live.py) were not run on the last commit.
Activity
10Review the following changes in direct dependencies. Learn more about Socket for GitHub.
| Diff | Package | Supply Chain Security | Vulnerability | Quality | Maintenance | License |
|---|---|---|---|---|---|---|
| pypi/claude-agent-sdk@0.2.179 |
This pull request is a draft
Merging is unavailable until it is marked ready for review.
The latest updates on your projects. Learn more about Vercel for GitHub.