[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-82848":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":14,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":15,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":16,"fork":16,"defaultBranch":17,"hasWiki":16,"hasPages":16,"topics":18,"createdAt":9,"pushedAt":9,"updatedAt":19,"readmeContent":20,"aiSummary":21,"trendingCount":14,"starSnapshotCount":14,"syncStatus":22,"lastSyncTime":23,"discoverSource":24},82848,"agent-runtime","Fennec-AI\u002Fagent-runtime","Fennec-AI","Python port of Claude Code's agent-runtime architecture, on LangChain",null,"Python",114,9,123,0,40,false,"main",[],"2026-06-12 04:01:39","# 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的agent-runtime架构。其核心功能包括异步生成器驱动的代理循环、支持层级传播和垃圾回收安全的取消控制器、模块级代理注册表以及通过`asyncio.Semaphore`控制并发。项目设计注重架构而非全面特性覆盖，并提供了易于扩展的接口。适用于需要灵活管理多个AI代理执行任务并能够优雅处理取消请求的应用场景，如多轮对话系统或复杂任务协调环境。当前处于基础架构完成阶段，后续将逐步引入工具调度等功能。",2,"2026-06-11 04:09:25","CREATED_QUERY"]