[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-79458":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":14,"stars30d":15,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":16,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":17,"fork":17,"defaultBranch":18,"hasWiki":17,"hasPages":17,"topics":19,"createdAt":9,"pushedAt":9,"updatedAt":20,"readmeContent":21,"aiSummary":22,"trendingCount":14,"starSnapshotCount":14,"syncStatus":23,"lastSyncTime":24,"discoverSource":25},79458,"agent-runtime","NabilAziz99\u002Fagent-runtime","NabilAziz99","Python port of Claude Code's agent-runtime architecture, on LangChain",null,"Python",123,9,103,0,19,3,false,"main",[],"2026-06-12 02:03:54","# agent_runtime — Python port of Claude Code's agent spawning architecture\n\nA clean, minimal Python implementation of the agent spawning patterns we\nreverse-engineered from Claude Code. Focuses on the *architecture*, not\nfeature completeness:\n\n- Async-generator-based agent loop (recursion = subagents)\n- `AbortController` with hierarchical, GC-safe cancellation\n- Module-level agent registry with push\u002Fdrain mailbox\n- Bounded concurrency via `asyncio.Semaphore` (coming in Step 2)\n- Extension points wired in from day 1 (compaction, hooks, etc.)\n\n**Built on LangChain.** Message types (HumanMessage, AIMessage, ToolMessage,\nSystemMessage), the chat model (BaseChatModel), and tools (BaseTool) all\ncome from `langchain_core`. The provider seam is `langchain_anthropic.ChatAnthropic`\nby default; swap in `ChatOpenAI`, `ChatGoogleGenerativeAI`, etc. without\ntouching agent code.\n\n## Status: Step 1 — foundation only\n\nThe architecture is in place; the dispatcher and tools aren't wired up yet\n(Step 2). Files:\n\n```\nagent_runtime\u002F\n├── __init__.py        # public API surface\n├── types.py           # ToolUseContext, QueryParams (rest is LangChain)\n├── cancel.py          # AbortController + hierarchical propagation\n├── registry.py        # AGENT_REGISTRY + inbox push\u002Fdrain\n├── query.py           # THE agent loop\n└── session.py         # Session (multi-turn session facade)\n```\n\n## Roadmap\n\n- **Step 1** ✅ Foundation (LangChain-based)\n- **Step 2** ⬜ Tool dispatcher (run_tools) + first runnable example\n- **Step 3** ⬜ AgentTool (the spawn!) + push-notification flow\n- **Step 4** ⬜ TaskStopTool — cancellation tool\n- **Step 5** ⬜ Compaction infrastructure\n- **Step 6** ⬜ Hooks (PreToolUse, PostToolUse, Stop)\n- **Later**  ⬜ Tombstones, depth caps, budget, persistence, telemetry\n\n## Setup\n\n```bash\npip install -r requirements.txt\nexport ANTHROPIC_API_KEY=...\n```\n\n## Minimal use (once Step 2 is done)\n\n```python\nimport asyncio\nfrom langchain_anthropic import ChatAnthropic\nfrom langchain_core.tools import tool\nfrom agent_runtime import Session\nfrom langchain_core.messages import AIMessageChunk\n\n@tool\ndef get_time() -> str:\n    \"\"\"Return the current time.\"\"\"\n    from datetime import datetime\n    return datetime.now().isoformat()\n\nasync def main():\n    engine = Session(\n        llm=ChatAnthropic(model=\"claude-sonnet-4-5\"),\n        tools=[get_time],\n    )\n    async for event in engine.submit_message(\"What time is it?\"):\n        if isinstance(event, AIMessageChunk):\n            print(event.content, end=\"\", flush=True)\n\nasyncio.run(main())\n```\n\n## Python version\n\nRequires Python 3.11+ for `asyncio.TaskGroup`, `asyncio.timeout`, modern\ntype-hint syntax (`X | Y`, `dict[K, V]`).\n","该项目是一个基于LangChain的Python实现，用于模拟Claude Code的代理运行时架构。其核心功能包括异步生成器驱动的代理循环、支持层级传播与垃圾回收安全的取消控制器、模块级代理注册表以及通过`asyncio.Semaphore`实现的并发限制。此外，项目从设计之初就预留了扩展点以支持后续功能如压缩、钩子等。适用于需要灵活构建和管理多代理系统的情景，特别是当这些代理需要在复杂任务中协作并处理异步消息流时。当前版本已奠定了基础架构，但工具调度器等功能仍在开发计划中。",2,"2026-06-01 03:48:39","CREATED_QUERY"]