Metadata-Version: 2.5
Name: ordin
Version: 0.1.1.dev1635051000000002001
Summary: Self-hosted GeneralAgent orchestration for Python
License: MIT
Requires-Python: >=3.12
Requires-Dist: openai>=2.53.0
Requires-Dist: pydantic>=2.11.0
Requires-Dist: pyyaml>=6.0.2
Description-Content-Type: text/markdown

# Ordin

Ordin 是模型中立、单进程生命周期的 Python Agent 编排库。平台先持久化 UserMessage，再把
`ExecutionRequest` 交给一个 `Ordin` 对象；根主控和开发者 Agent 都使用同一个公共
`GeneralAgent` 类型、同一 Context/模型/Tool/Artifact 生命周期。

根 GeneralAgent 可以通过受控 Tool 创建 Task DAG、选择已注册 Agent 与模型、并发执行子 Agent、
等待结果并完成最终综合。Provider、Store、ObjectStore 和注册表由 Ordin 持有，不进入 Agent 定义。

## 安装

```bash
pip install ordin
```

## 最小示例

```python
from ordin import GeneralAgent, Ordin
from ordin.common import Identity
from ordin.llm import LLMCallPipeline, LLMProfile
from ordin.observability import EventBroker
from ordin.testing import InMemoryObjectStore, InMemoryOrdinBackend

backend = InMemoryOrdinBackend()
events = EventBroker(backend)
model = LLMCallPipeline(
    provider=my_llm_provider,
    recorder=backend,
    event_sink=events,
).bind(LLMProfile(id="private-model"))

ordin = Ordin(
    root_agent=GeneralAgent[None](
        name="root",
        instructions="Answer directly or create bounded child Agents when useful.",
        model=model.id,
    ),
    models=(model,),
    backend=backend,
    object_store=InMemoryObjectStore(),
    events=events,
)

ordin.register(
    GeneralAgent[None](
        name="research",
        description="Produce bounded research evidence.",
        instructions="Complete only the current Task.",
        model=model.id,
    )
)

request = await backend.prepare_execution(
    "分析这个问题",
    identity=Identity(user_id="u-1"),
)
result = await ordin.execute(request, context=None)
```

完整离线示例见 [`examples/direct.py`](examples/direct.py)、
[`examples/mission.py`](examples/mission.py) 和
[`examples/custom_agent.py`](examples/custom_agent.py)。

## 文档

- [文档入口](docs/index.md)
- [架构总览](docs/architecture/overview.md)
- [根 Agent 编排](docs/architecture/orchestration.md)
- [Context 与模型调用](docs/architecture/context.md)
- [GeneralAgent 模块](docs/modules/agent.md)
- [快速开始](docs/guides/quickstart.md)
- [ADR-0001：GeneralAgent 自托管](docs/adr/0001-general-agent-self-hosting.md)
- [ADR-0008：绑定模型与受约束选择](docs/adr/0008-bound-model-selection.md)

## 开发校验

```bash
uv sync
uv run python scripts/docs.py --check
uv run pytest tests/test_docs.py
uv run ruff format .
uv run ruff check .
uv run ty check
uv run pytest
```
