arcana-agent 0.1.0b1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arcana_agent-0.1.0b1/.env.example +41 -0
- arcana_agent-0.1.0b1/.github/workflows/ci.yml +32 -0
- arcana_agent-0.1.0b1/.gitignore +35 -0
- arcana_agent-0.1.0b1/.python-version +1 -0
- arcana_agent-0.1.0b1/CHANGELOG.md +99 -0
- arcana_agent-0.1.0b1/CLAUDE.md +168 -0
- arcana_agent-0.1.0b1/CONSTITUTION.md +191 -0
- arcana_agent-0.1.0b1/CONTRIBUTING.md +90 -0
- arcana_agent-0.1.0b1/LICENSE +21 -0
- arcana_agent-0.1.0b1/Makefile +28 -0
- arcana_agent-0.1.0b1/PKG-INFO +249 -0
- arcana_agent-0.1.0b1/README.md +204 -0
- arcana_agent-0.1.0b1/docs/architecture.md +542 -0
- arcana_agent-0.1.0b1/docs/legacy/KNOWLEDGE.md +1596 -0
- arcana_agent-0.1.0b1/docs/legacy/LEARNING_ROADMAP.md +448 -0
- arcana_agent-0.1.0b1/docs/legacy/RUNTIME_KNOWLEDGE.md +1069 -0
- arcana_agent-0.1.0b1/docs/legacy/TUTORIAL.md +240 -0
- arcana_agent-0.1.0b1/docs/legacy/WEEK3-4_RUNTIME_LEARNING.md +988 -0
- arcana_agent-0.1.0b1/docs/legacy/graph-engine-todo.md +151 -0
- arcana_agent-0.1.0b1/docs/legacy/tutorial_part1.md +1572 -0
- arcana_agent-0.1.0b1/docs/legacy/tutorial_part2.md +950 -0
- arcana_agent-0.1.0b1/docs/legacy/tutorial_part3.md +1690 -0
- arcana_agent-0.1.0b1/docs/legacy/tutorial_part4.md +1310 -0
- arcana_agent-0.1.0b1/docs/legacy/tutorial_part5.md +1338 -0
- arcana_agent-0.1.0b1/docs/specs/rag_spec.md +263 -0
- arcana_agent-0.1.0b1/docs/specs/state_spec.md +225 -0
- arcana_agent-0.1.0b1/docs/specs/tool_spec.md +213 -0
- arcana_agent-0.1.0b1/docs/specs/trace_spec.md +161 -0
- arcana_agent-0.1.0b1/examples/01_hello.py +36 -0
- arcana_agent-0.1.0b1/examples/02_with_tools.py +43 -0
- arcana_agent-0.1.0b1/examples/03_adaptive_policy.py +44 -0
- arcana_agent-0.1.0b1/examples/04_intent_router.py +54 -0
- arcana_agent-0.1.0b1/examples/05_budget_control.py +49 -0
- arcana_agent-0.1.0b1/examples/06_conversation_agent.py +184 -0
- arcana_agent-0.1.0b1/examples/07_full_demo.py +312 -0
- arcana_agent-0.1.0b1/examples/08_fastapi_integration.py +73 -0
- arcana_agent-0.1.0b1/examples/09_multi_agent.py +62 -0
- arcana_agent-0.1.0b1/examples/10_tool_with_runtime.py +88 -0
- arcana_agent-0.1.0b1/examples/11_advanced_memory.py +146 -0
- arcana_agent-0.1.0b1/examples/12_graph_orchestration.py +209 -0
- arcana_agent-0.1.0b1/examples/README.md +24 -0
- arcana_agent-0.1.0b1/pyproject.toml +90 -0
- arcana_agent-0.1.0b1/src/arcana/__init__.py +18 -0
- arcana_agent-0.1.0b1/src/arcana/cli/__init__.py +0 -0
- arcana_agent-0.1.0b1/src/arcana/cli/main.py +251 -0
- arcana_agent-0.1.0b1/src/arcana/context/__init__.py +1 -0
- arcana_agent-0.1.0b1/src/arcana/context/builder.py +209 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/__init__.py +59 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/context.py +68 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/diagnosis.py +177 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/eval.py +78 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/graph.py +68 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/intent.py +26 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/llm.py +362 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/mcp.py +71 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/memory.py +109 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/multi_agent.py +63 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/orchestrator.py +81 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/plan.py +101 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/rag.py +130 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/routing.py +60 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/runtime.py +94 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/state.py +96 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/strategy.py +42 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/streaming.py +99 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/tool.py +108 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/trace.py +153 -0
- arcana_agent-0.1.0b1/src/arcana/contracts/turn.py +51 -0
- arcana_agent-0.1.0b1/src/arcana/eval/__init__.py +25 -0
- arcana_agent-0.1.0b1/src/arcana/eval/gate.py +101 -0
- arcana_agent-0.1.0b1/src/arcana/eval/judge.py +125 -0
- arcana_agent-0.1.0b1/src/arcana/eval/metrics.py +43 -0
- arcana_agent-0.1.0b1/src/arcana/eval/runner.py +171 -0
- arcana_agent-0.1.0b1/src/arcana/eval/v2_runner.py +117 -0
- arcana_agent-0.1.0b1/src/arcana/gateway/__init__.py +7 -0
- arcana_agent-0.1.0b1/src/arcana/gateway/base.py +205 -0
- arcana_agent-0.1.0b1/src/arcana/gateway/budget.py +144 -0
- arcana_agent-0.1.0b1/src/arcana/gateway/capabilities.py +209 -0
- arcana_agent-0.1.0b1/src/arcana/gateway/providers/__init__.py +53 -0
- arcana_agent-0.1.0b1/src/arcana/gateway/providers/anthropic.py +523 -0
- arcana_agent-0.1.0b1/src/arcana/gateway/providers/deepseek.py +62 -0
- arcana_agent-0.1.0b1/src/arcana/gateway/providers/gemini.py +64 -0
- arcana_agent-0.1.0b1/src/arcana/gateway/providers/openai_compatible.py +455 -0
- arcana_agent-0.1.0b1/src/arcana/gateway/registry.py +184 -0
- arcana_agent-0.1.0b1/src/arcana/gateway/router.py +200 -0
- arcana_agent-0.1.0b1/src/arcana/graph/__init__.py +66 -0
- arcana_agent-0.1.0b1/src/arcana/graph/checkpointer.py +76 -0
- arcana_agent-0.1.0b1/src/arcana/graph/compiled_graph.py +128 -0
- arcana_agent-0.1.0b1/src/arcana/graph/constants.py +4 -0
- arcana_agent-0.1.0b1/src/arcana/graph/executor.py +306 -0
- arcana_agent-0.1.0b1/src/arcana/graph/interrupt.py +32 -0
- arcana_agent-0.1.0b1/src/arcana/graph/node_runner.py +106 -0
- arcana_agent-0.1.0b1/src/arcana/graph/nodes/__init__.py +7 -0
- arcana_agent-0.1.0b1/src/arcana/graph/nodes/llm_node.py +73 -0
- arcana_agent-0.1.0b1/src/arcana/graph/nodes/subgraph_node.py +58 -0
- arcana_agent-0.1.0b1/src/arcana/graph/nodes/tool_node.py +71 -0
- arcana_agent-0.1.0b1/src/arcana/graph/prebuilt/__init__.py +6 -0
- arcana_agent-0.1.0b1/src/arcana/graph/prebuilt/plan_execute.py +162 -0
- arcana_agent-0.1.0b1/src/arcana/graph/prebuilt/react_agent.py +82 -0
- arcana_agent-0.1.0b1/src/arcana/graph/reducers.py +106 -0
- arcana_agent-0.1.0b1/src/arcana/graph/state_graph.py +257 -0
- arcana_agent-0.1.0b1/src/arcana/graph/streaming.py +112 -0
- arcana_agent-0.1.0b1/src/arcana/mcp/__init__.py +1 -0
- arcana_agent-0.1.0b1/src/arcana/mcp/client.py +207 -0
- arcana_agent-0.1.0b1/src/arcana/mcp/protocol.py +121 -0
- arcana_agent-0.1.0b1/src/arcana/mcp/setup.py +48 -0
- arcana_agent-0.1.0b1/src/arcana/mcp/tool_provider.py +62 -0
- arcana_agent-0.1.0b1/src/arcana/mcp/transport/__init__.py +0 -0
- arcana_agent-0.1.0b1/src/arcana/mcp/transport/base.py +37 -0
- arcana_agent-0.1.0b1/src/arcana/mcp/transport/stdio.py +94 -0
- arcana_agent-0.1.0b1/src/arcana/memory/__init__.py +39 -0
- arcana_agent-0.1.0b1/src/arcana/memory/episodic.py +102 -0
- arcana_agent-0.1.0b1/src/arcana/memory/governance.py +55 -0
- arcana_agent-0.1.0b1/src/arcana/memory/long_term.py +131 -0
- arcana_agent-0.1.0b1/src/arcana/memory/manager.py +181 -0
- arcana_agent-0.1.0b1/src/arcana/memory/run_memory.py +302 -0
- arcana_agent-0.1.0b1/src/arcana/memory/working.py +91 -0
- arcana_agent-0.1.0b1/src/arcana/multi_agent/__init__.py +36 -0
- arcana_agent-0.1.0b1/src/arcana/multi_agent/message_bus.py +85 -0
- arcana_agent-0.1.0b1/src/arcana/multi_agent/team.py +390 -0
- arcana_agent-0.1.0b1/src/arcana/observability/__init__.py +12 -0
- arcana_agent-0.1.0b1/src/arcana/observability/hooks.py +126 -0
- arcana_agent-0.1.0b1/src/arcana/observability/metrics.py +166 -0
- arcana_agent-0.1.0b1/src/arcana/orchestrator/__init__.py +35 -0
- arcana_agent-0.1.0b1/src/arcana/orchestrator/executor_pool.py +154 -0
- arcana_agent-0.1.0b1/src/arcana/orchestrator/hooks.py +42 -0
- arcana_agent-0.1.0b1/src/arcana/orchestrator/orchestrator.py +237 -0
- arcana_agent-0.1.0b1/src/arcana/orchestrator/scheduler.py +71 -0
- arcana_agent-0.1.0b1/src/arcana/orchestrator/task_graph.py +180 -0
- arcana_agent-0.1.0b1/src/arcana/py.typed +0 -0
- arcana_agent-0.1.0b1/src/arcana/rag/__init__.py +18 -0
- arcana_agent-0.1.0b1/src/arcana/rag/chunker.py +187 -0
- arcana_agent-0.1.0b1/src/arcana/rag/embedder.py +103 -0
- arcana_agent-0.1.0b1/src/arcana/rag/reranker.py +155 -0
- arcana_agent-0.1.0b1/src/arcana/rag/retriever.py +178 -0
- arcana_agent-0.1.0b1/src/arcana/rag/verifier.py +135 -0
- arcana_agent-0.1.0b1/src/arcana/routing/__init__.py +17 -0
- arcana_agent-0.1.0b1/src/arcana/routing/classifier.py +288 -0
- arcana_agent-0.1.0b1/src/arcana/routing/executor.py +163 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/__init__.py +57 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/agent.py +859 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/conversation.py +582 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/diagnosis/__init__.py +17 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/diagnosis/diagnoser.py +573 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/diagnosis/tracker.py +140 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/error_handler.py +255 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/exceptions.py +115 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/factory.py +85 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/hooks/__init__.py +9 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/hooks/base.py +62 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/hooks/memory_hook.py +100 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/policies/__init__.py +8 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/policies/adaptive.py +367 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/policies/base.py +45 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/policies/plan_execute.py +276 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/policies/react.py +92 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/progress.py +157 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/reducers/__init__.py +7 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/reducers/base.py +43 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/reducers/default.py +102 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/reducers/plan_reducer.py +137 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/replay.py +389 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/state_manager.py +245 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/step.py +634 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/validator.py +249 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/verifiers/__init__.py +6 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/verifiers/base.py +37 -0
- arcana_agent-0.1.0b1/src/arcana/runtime/verifiers/goal_verifier.py +140 -0
- arcana_agent-0.1.0b1/src/arcana/runtime_core.py +766 -0
- arcana_agent-0.1.0b1/src/arcana/sdk.py +245 -0
- arcana_agent-0.1.0b1/src/arcana/storage/__init__.py +19 -0
- arcana_agent-0.1.0b1/src/arcana/storage/base.py +147 -0
- arcana_agent-0.1.0b1/src/arcana/storage/chroma.py +175 -0
- arcana_agent-0.1.0b1/src/arcana/storage/memory.py +228 -0
- arcana_agent-0.1.0b1/src/arcana/storage/postgres.py +399 -0
- arcana_agent-0.1.0b1/src/arcana/streaming/__init__.py +1 -0
- arcana_agent-0.1.0b1/src/arcana/streaming/sse.py +16 -0
- arcana_agent-0.1.0b1/src/arcana/tool_gateway/__init__.py +27 -0
- arcana_agent-0.1.0b1/src/arcana/tool_gateway/adapters/__init__.py +0 -0
- arcana_agent-0.1.0b1/src/arcana/tool_gateway/adapters/langchain.py +113 -0
- arcana_agent-0.1.0b1/src/arcana/tool_gateway/base.py +55 -0
- arcana_agent-0.1.0b1/src/arcana/tool_gateway/formatter.py +75 -0
- arcana_agent-0.1.0b1/src/arcana/tool_gateway/gateway.py +417 -0
- arcana_agent-0.1.0b1/src/arcana/tool_gateway/lazy_registry.py +248 -0
- arcana_agent-0.1.0b1/src/arcana/tool_gateway/registry.py +101 -0
- arcana_agent-0.1.0b1/src/arcana/tool_gateway/validators.py +89 -0
- arcana_agent-0.1.0b1/src/arcana/trace/__init__.py +6 -0
- arcana_agent-0.1.0b1/src/arcana/trace/reader.py +239 -0
- arcana_agent-0.1.0b1/src/arcana/trace/writer.py +132 -0
- arcana_agent-0.1.0b1/src/arcana/utils/__init__.py +6 -0
- arcana_agent-0.1.0b1/src/arcana/utils/config.py +144 -0
- arcana_agent-0.1.0b1/src/arcana/utils/hashing.py +92 -0
- arcana_agent-0.1.0b1/tests/__init__.py +1 -0
- arcana_agent-0.1.0b1/tests/conftest.py +19 -0
- arcana_agent-0.1.0b1/tests/integration/__init__.py +0 -0
- arcana_agent-0.1.0b1/tests/integration/ab_comparison.py +211 -0
- arcana_agent-0.1.0b1/tests/integration/test_deepseek_e2e.py +524 -0
- arcana_agent-0.1.0b1/tests/test_checkpoint_resume.py +757 -0
- arcana_agent-0.1.0b1/tests/test_chroma_storage.py +107 -0
- arcana_agent-0.1.0b1/tests/test_cli.py +45 -0
- arcana_agent-0.1.0b1/tests/test_context.py +148 -0
- arcana_agent-0.1.0b1/tests/test_conversation.py +464 -0
- arcana_agent-0.1.0b1/tests/test_e2e.py +1213 -0
- arcana_agent-0.1.0b1/tests/test_eval.py +351 -0
- arcana_agent-0.1.0b1/tests/test_graph_builder.py +322 -0
- arcana_agent-0.1.0b1/tests/test_graph_checkpoint.py +173 -0
- arcana_agent-0.1.0b1/tests/test_graph_execution.py +638 -0
- arcana_agent-0.1.0b1/tests/test_graph_prebuilt.py +300 -0
- arcana_agent-0.1.0b1/tests/test_graph_streaming.py +130 -0
- arcana_agent-0.1.0b1/tests/test_mcp.py +285 -0
- arcana_agent-0.1.0b1/tests/test_memory.py +705 -0
- arcana_agent-0.1.0b1/tests/test_multi_agent.py +642 -0
- arcana_agent-0.1.0b1/tests/test_observability.py +267 -0
- arcana_agent-0.1.0b1/tests/test_orchestrator.py +558 -0
- arcana_agent-0.1.0b1/tests/test_plan_execute.py +915 -0
- arcana_agent-0.1.0b1/tests/test_rag.py +782 -0
- arcana_agent-0.1.0b1/tests/test_routing.py +64 -0
- arcana_agent-0.1.0b1/tests/test_runtime.py +197 -0
- arcana_agent-0.1.0b1/tests/test_runtime_core.py +279 -0
- arcana_agent-0.1.0b1/tests/test_runtime_integration.py +317 -0
- arcana_agent-0.1.0b1/tests/test_sdk.py +294 -0
- arcana_agent-0.1.0b1/tests/test_storage.py +398 -0
- arcana_agent-0.1.0b1/tests/test_tool_gateway.py +975 -0
- arcana_agent-0.1.0b1/tests/test_tool_integration.py +255 -0
- arcana_agent-0.1.0b1/uv.lock +2631 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Arcana Agent Platform - Environment Variables
|
|
2
|
+
|
|
3
|
+
# ===== DeepSeek (verified) =====
|
|
4
|
+
DEEPSEEK_API_KEY=sk-xxx
|
|
5
|
+
DEEPSEEK_BASE_URL=https://api.deepseek.com
|
|
6
|
+
DEEPSEEK_MODEL=deepseek-chat
|
|
7
|
+
|
|
8
|
+
# ===== OpenAI (verified) =====
|
|
9
|
+
OPENAI_API_KEY=sk-xxx
|
|
10
|
+
|
|
11
|
+
# ===== Anthropic (verified) =====
|
|
12
|
+
ANTHROPIC_API_KEY=sk-ant-xxx
|
|
13
|
+
|
|
14
|
+
# ===== Gemini (OpenAI Compatible) =====
|
|
15
|
+
GEMINI_API_KEY=AIza-xxx
|
|
16
|
+
GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai
|
|
17
|
+
GEMINI_MODEL=gemini-2.0-flash
|
|
18
|
+
|
|
19
|
+
# ===== Kimi (月之暗面) =====
|
|
20
|
+
KIMI_API_KEY=sk-xxx
|
|
21
|
+
|
|
22
|
+
# ===== GLM (智谱) =====
|
|
23
|
+
GLM_API_KEY=xxx
|
|
24
|
+
|
|
25
|
+
# ===== MiniMax =====
|
|
26
|
+
MINIMAX_API_KEY=xxx
|
|
27
|
+
|
|
28
|
+
# ===== Trace Configuration =====
|
|
29
|
+
TRACE_DIR=./traces
|
|
30
|
+
TRACE_ENABLED=true
|
|
31
|
+
|
|
32
|
+
# ===== Default Model Configuration =====
|
|
33
|
+
DEFAULT_PROVIDER=deepseek
|
|
34
|
+
DEFAULT_MODEL=deepseek-chat
|
|
35
|
+
DEFAULT_TEMPERATURE=0.0
|
|
36
|
+
DEFAULT_MAX_TOKENS=4096
|
|
37
|
+
DEFAULT_TIMEOUT_MS=30000
|
|
38
|
+
|
|
39
|
+
# ===== Budget Limits =====
|
|
40
|
+
MAX_TOKENS_PER_RUN=100000
|
|
41
|
+
MAX_COST_PER_RUN_USD=1.0
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.11", "3.12"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v4
|
|
21
|
+
|
|
22
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
23
|
+
run: uv python install ${{ matrix.python-version }}
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: uv sync --all-extras
|
|
27
|
+
|
|
28
|
+
- name: Lint
|
|
29
|
+
run: uv run ruff check .
|
|
30
|
+
|
|
31
|
+
- name: Test
|
|
32
|
+
run: uv run pytest -x -q
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv
|
|
11
|
+
|
|
12
|
+
# Environment variables
|
|
13
|
+
.env
|
|
14
|
+
.env.local
|
|
15
|
+
|
|
16
|
+
# IDE
|
|
17
|
+
.idea/
|
|
18
|
+
.vscode/
|
|
19
|
+
*.swp
|
|
20
|
+
*.swo
|
|
21
|
+
|
|
22
|
+
# Testing
|
|
23
|
+
.pytest_cache/
|
|
24
|
+
.coverage
|
|
25
|
+
htmlcov/
|
|
26
|
+
.mypy_cache/
|
|
27
|
+
.ruff_cache/
|
|
28
|
+
|
|
29
|
+
# Traces (local development)
|
|
30
|
+
traces/
|
|
31
|
+
*.jsonl
|
|
32
|
+
|
|
33
|
+
# OS files
|
|
34
|
+
.DS_Store
|
|
35
|
+
Thumbs.db
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.11
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to Arcana will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [0.1.0-beta.1] - 2026-03-18
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Runtime + Session**: Long-lived resource container, create once use everywhere
|
|
9
|
+
- **Runtime.team()**: Multi-agent collaboration (constitutional — Runtime provides comm, agents decide strategy)
|
|
10
|
+
- **Runtime.stream()**: Async generator for streaming
|
|
11
|
+
- **Runtime.graph()**: StateGraph factory
|
|
12
|
+
- **Memory v2**: Relevance-based retrieval (keyword + recency + importance + token budget)
|
|
13
|
+
- **MCP Client**: stdio transport, MCPToolProvider → ToolGateway bridge
|
|
14
|
+
- **CLI**: `arcana run/trace/providers/version`
|
|
15
|
+
- **ConversationAgent (V2)**: TurnFacts/TurnAssessment separation, 51% token savings
|
|
16
|
+
- **108 new tests**: All user-facing modules now covered (713 total)
|
|
17
|
+
- **Actionable error messages**: 8 files improved
|
|
18
|
+
- **Intent Router**: Default on in ConversationAgent
|
|
19
|
+
- **Diagnostic Recovery**: Structured diagnosis in V2
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- `arcana.run()` delegates to Runtime, accepts `api_key` param
|
|
23
|
+
- Default engine is V2 ConversationAgent
|
|
24
|
+
- Hardcoded model IDs removed — user explicit > provider default > error
|
|
25
|
+
- README → "Agent Runtime for Production"
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- AdaptivePolicy execution closure
|
|
29
|
+
- Memory injection through direct_answer fast path
|
|
30
|
+
- Tool results use native OpenAI format
|
|
31
|
+
- single_tool argument generation
|
|
32
|
+
|
|
33
|
+
## [0.1.0-alpha.2] - 2026-03-18
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- `arcana.run()` now accepts `api_key` parameter — no .env file needed
|
|
37
|
+
- Default engine switched to ConversationAgent (V2)
|
|
38
|
+
- `max_steps` renamed to `max_turns` in `arcana.run()`
|
|
39
|
+
- `engine="conversation"` (default) or `engine="adaptive"` (V1)
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
- SDK no longer forces environment variables for API keys
|
|
43
|
+
- OpenAI and Anthropic providers now work in `arcana.run()`
|
|
44
|
+
- Clear error message when no API key provided
|
|
45
|
+
|
|
46
|
+
## [0.1.0-alpha.1] - 2026-03-18
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
|
|
50
|
+
#### V2 Execution Engine
|
|
51
|
+
- **ConversationAgent**: LLM-native execution model with TurnFacts/TurnAssessment separation
|
|
52
|
+
- **TurnFacts**: Raw provider output, zero interpretation
|
|
53
|
+
- **TurnAssessment**: Runtime completion/failure judgment, separate from facts
|
|
54
|
+
- 13-step turn contract with 7 invariants
|
|
55
|
+
- Streaming via `ConversationAgent.astream()`
|
|
56
|
+
|
|
57
|
+
#### V2 Architecture
|
|
58
|
+
- **CONSTITUTION.md**: 7 design principles, 4 prohibitions
|
|
59
|
+
- **Intent Router**: Rule-based + LLM + Hybrid classifiers, 4 execution paths
|
|
60
|
+
- **Adaptive Policy**: 6 strategy types (direct_answer, single_tool, sequential, parallel, plan_and_execute, pivot)
|
|
61
|
+
- **Lazy Tool Loading**: Keyword-based tool selection, affordance fields on ToolSpec
|
|
62
|
+
- **Diagnostic Recovery**: 7 error categories, structured feedback, RecoveryTracker
|
|
63
|
+
- **Multi-Model Routing**: 5 model roles, complexity-based selection
|
|
64
|
+
- **Working Set Builder**: 4-layer context management (identity/task/working/external)
|
|
65
|
+
|
|
66
|
+
#### Provider Infrastructure
|
|
67
|
+
- **BaseProvider Protocol**: Replaces ABC, maps to Rust trait
|
|
68
|
+
- **AnthropicProvider**: Native Claude support with extended thinking
|
|
69
|
+
- **Chinese Providers**: Kimi (Moonshot), GLM (Zhipu), MiniMax factory functions
|
|
70
|
+
- **Capability Registry**: 22 capabilities across 8 providers
|
|
71
|
+
- **Error Hierarchy**: RateLimitError, AuthenticationError, ModelNotFoundError, ContentFilterError, ContextLengthError
|
|
72
|
+
- **StreamChunk**: Unified streaming data model
|
|
73
|
+
|
|
74
|
+
#### SDK
|
|
75
|
+
- `arcana.run()`: Zero-config entry point
|
|
76
|
+
- `@arcana.tool`: Decorator with affordance fields (when_to_use, what_to_expect, failure_meaning)
|
|
77
|
+
- `RunResult`: Structured result with output, steps, tokens, cost
|
|
78
|
+
- Budget tracking wired into SDK
|
|
79
|
+
|
|
80
|
+
#### Evaluation
|
|
81
|
+
- EvalMetrics: first_attempt_success, goal_achievement_rate, cost_per_success
|
|
82
|
+
- RuleJudge + LLMJudge + HybridJudge
|
|
83
|
+
- EvalRunnerV2 with suite reporting
|
|
84
|
+
|
|
85
|
+
#### Code Quality
|
|
86
|
+
- 605 tests, 0 failures
|
|
87
|
+
- Verified with real APIs: DeepSeek, OpenAI (gpt-4o-mini), Anthropic (claude-sonnet-4)
|
|
88
|
+
- AgentState immutable pattern
|
|
89
|
+
- ToolProvider ABC → Protocol
|
|
90
|
+
- asyncio.Lock replaces threading.Lock
|
|
91
|
+
|
|
92
|
+
### V1 (Preserved)
|
|
93
|
+
- Agent + AdaptivePolicy + StepExecutor + Reducer pipeline
|
|
94
|
+
- ReAct and PlanExecute policies
|
|
95
|
+
- Graph engine (StateGraph, CompiledGraph)
|
|
96
|
+
- Multi-agent orchestration (TeamOrchestrator)
|
|
97
|
+
- JSONL Trace system
|
|
98
|
+
- Budget tracking
|
|
99
|
+
- Checkpoint/Resume
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Build & Development Commands
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install all dependencies (including dev)
|
|
9
|
+
uv sync --all-extras
|
|
10
|
+
|
|
11
|
+
# Run tests
|
|
12
|
+
uv run pytest
|
|
13
|
+
|
|
14
|
+
# Run single test file
|
|
15
|
+
uv run pytest tests/test_trace.py
|
|
16
|
+
|
|
17
|
+
# Run tests with coverage
|
|
18
|
+
uv run pytest --cov=arcana
|
|
19
|
+
|
|
20
|
+
# Lint
|
|
21
|
+
uv run ruff check .
|
|
22
|
+
|
|
23
|
+
# Type check (strict mode)
|
|
24
|
+
uv run mypy src/
|
|
25
|
+
|
|
26
|
+
# Run integration tests (requires API keys via env vars or .env)
|
|
27
|
+
uv run pytest tests/integration/ -v
|
|
28
|
+
|
|
29
|
+
# Run demo
|
|
30
|
+
uv run python examples/demo_trace.py
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Architecture Overview
|
|
34
|
+
|
|
35
|
+
Arcana is an Agent Platform following a "contracts-first" design. All modules define Pydantic schemas before implementation, enabling future language migrations (Go/Rust) without changing upper-layer logic.
|
|
36
|
+
|
|
37
|
+
### V2 Architecture (current)
|
|
38
|
+
|
|
39
|
+
The V2 engine centers on `ConversationAgent` — no Policy, no Reducer, just LLM turns. Each turn produces `TurnFacts` (raw LLM output) and `TurnAssessment` (runtime interpretation), kept visibly separate.
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
Request → Intent Router (routing/)
|
|
43
|
+
→ Direct Answer (1 LLM call)
|
|
44
|
+
→ ConversationAgent (runtime/conversation.py)
|
|
45
|
+
LLM Turn → TurnFacts → TurnAssessment → State
|
|
46
|
+
Runtime OS: Budget | Trace | Tools | Diagnostics
|
|
47
|
+
|
|
48
|
+
V1 path (still compatible):
|
|
49
|
+
→ Agent + AdaptivePolicy (runtime/agent.py)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Layer Structure
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
┌─────────────────────────────────────────────────┐
|
|
56
|
+
│ Application (Agents) │
|
|
57
|
+
│ runtime/conversation.py (V2 ConversationAgent)│
|
|
58
|
+
│ runtime/agent.py (V1 Agent) │
|
|
59
|
+
├─────────────────────────────────────────────────┤
|
|
60
|
+
│ Routing │ Gateway │ Tool Gateway │ Context │ ← Platform Services
|
|
61
|
+
│ Eval │ Memory │ Streaming │ Diagnosis │
|
|
62
|
+
├─────────────────────────────────────────────────┤
|
|
63
|
+
│ Contracts (Pydantic Schemas) │ ← Data Models
|
|
64
|
+
│ turn, routing, context, diagnosis, llm, tool │
|
|
65
|
+
├─────────────────────────────────────────────────┤
|
|
66
|
+
│ Trace (JSONL Audit Log) │ ← Observability
|
|
67
|
+
└─────────────────────────────────────────────────┘
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Core Modules
|
|
71
|
+
|
|
72
|
+
**contracts/** - All data models:
|
|
73
|
+
- `turn.py`: `TurnFacts`, `TurnAssessment` — the V2 separation principle
|
|
74
|
+
- `routing.py`: `RoutingDecision`, `IntentCategory` — intent classification
|
|
75
|
+
- `context.py`: `ContextBlock`, `ContextBudget` — working set context
|
|
76
|
+
- `diagnosis.py`: `DiagnosticBrief`, `ErrorCategory` — structured error recovery
|
|
77
|
+
- `llm.py`: `LLMRequest`, `LLMResponse`, `ModelConfig` — unified LLM interface
|
|
78
|
+
- `tool.py`: `ToolSpec`, `ToolCall`, `ToolResult` — tool execution contracts
|
|
79
|
+
- `state.py`: `AgentState` — execution state with budget tracking
|
|
80
|
+
- `runtime.py`: Runtime configuration and turn state
|
|
81
|
+
- `eval.py`: Evaluation framework contracts
|
|
82
|
+
- `streaming.py`: Streaming response contracts
|
|
83
|
+
- `multi_agent.py`: Multi-agent coordination contracts
|
|
84
|
+
- `plan.py`, `strategy.py`, `intent.py`, `graph.py`, `orchestrator.py`, `memory.py`, `rag.py`
|
|
85
|
+
|
|
86
|
+
**runtime/** - Agent execution engines:
|
|
87
|
+
- `conversation.py`: `ConversationAgent` — the V2 engine (recommended)
|
|
88
|
+
- `agent.py`: V1 agent with AdaptivePolicy
|
|
89
|
+
- `state_manager.py`: State lifecycle management
|
|
90
|
+
- `step.py`: Single-step execution
|
|
91
|
+
- `error_handler.py`: Runtime error handling
|
|
92
|
+
- `validator.py`: Input/output validation
|
|
93
|
+
- `factory.py`: Agent factory
|
|
94
|
+
- `replay.py`: Trace replay for debugging
|
|
95
|
+
- `progress.py`: Progress tracking
|
|
96
|
+
|
|
97
|
+
**routing/** - Intent classification and routing:
|
|
98
|
+
- `classifier.py`: Rule-based + LLM fallback intent classifier
|
|
99
|
+
- `executor.py`: Route execution (direct answer vs agent loop)
|
|
100
|
+
|
|
101
|
+
**context/** - Working set context management:
|
|
102
|
+
- `builder.py`: Context block assembly and budget enforcement
|
|
103
|
+
|
|
104
|
+
**gateway/** - Model Gateway with provider abstraction:
|
|
105
|
+
- `ModelGatewayRegistry`: Multi-provider routing with fallback chains
|
|
106
|
+
- `OpenAICompatibleProvider`: Universal adapter for OpenAI-format APIs
|
|
107
|
+
- Provider factories: DeepSeek, OpenAI, Anthropic, Kimi, GLM, MiniMax, Gemini, Ollama
|
|
108
|
+
|
|
109
|
+
**tool_gateway/** - Tool execution with auth, validation, audit
|
|
110
|
+
|
|
111
|
+
**eval/** - Evaluation framework for agent quality
|
|
112
|
+
|
|
113
|
+
**trace/** - JSONL-based event logging
|
|
114
|
+
|
|
115
|
+
**multi_agent/** - Multi-agent coordination
|
|
116
|
+
|
|
117
|
+
**streaming/** - Streaming response support
|
|
118
|
+
|
|
119
|
+
### Key Design Patterns
|
|
120
|
+
|
|
121
|
+
1. **TurnFacts / TurnAssessment Separation**: The LLM produces facts (what it said, what tools it called). The runtime produces assessment (should we continue, is budget exceeded, did a tool fail). Never mix the two — the LLM does not judge its own output; the runtime does not generate content.
|
|
122
|
+
|
|
123
|
+
2. **Canonical Hashing**: All digests use SHA-256 on sorted JSON, truncated to 16 chars. See `utils/hashing.py`.
|
|
124
|
+
|
|
125
|
+
3. **Provider Abstraction**: Single `OpenAICompatibleProvider` handles any OpenAI-format API by changing base_url. Adding a new provider is one function call.
|
|
126
|
+
|
|
127
|
+
4. **Trace Everything**: Every LLM call auto-logs to trace with request/response digests.
|
|
128
|
+
|
|
129
|
+
5. **Contracts First**: All data flows through Pydantic models defined in `contracts/`. Implementation never invents ad-hoc dicts.
|
|
130
|
+
|
|
131
|
+
## Configuration
|
|
132
|
+
|
|
133
|
+
Pass `api_key` directly to `arcana.run()` — no `.env` file required:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
result = await arcana.run("Hello", api_key="sk-xxx")
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Environment variables are still supported as a fallback:
|
|
140
|
+
- `DEEPSEEK_API_KEY` (primary, verified)
|
|
141
|
+
- `OPENAI_API_KEY` (verified)
|
|
142
|
+
- `ANTHROPIC_API_KEY` (verified)
|
|
143
|
+
- `GEMINI_API_KEY`, `KIMI_API_KEY`, `GLM_API_KEY`, `MINIMAX_API_KEY` (supported)
|
|
144
|
+
|
|
145
|
+
## Verified Providers
|
|
146
|
+
|
|
147
|
+
These providers have been tested with real API keys:
|
|
148
|
+
- DeepSeek (deepseek-chat) — direct answer + tools + multi-step
|
|
149
|
+
- OpenAI (gpt-4o-mini) — direct answer + tools
|
|
150
|
+
- Anthropic (claude-sonnet-4) — direct answer
|
|
151
|
+
|
|
152
|
+
## SDK Interface (`sdk.py`)
|
|
153
|
+
|
|
154
|
+
Key parameters for `arcana.run()`:
|
|
155
|
+
- `api_key`: API key string (preferred over env vars)
|
|
156
|
+
- `provider`: Provider name (`"deepseek"`, `"openai"`, `"anthropic"`, etc.)
|
|
157
|
+
- `engine`: `"conversation"` (default, V2 ConversationAgent) or `"adaptive"` (V1)
|
|
158
|
+
- `max_turns`: Maximum number of agent turns (renamed from `max_steps`)
|
|
159
|
+
- `tools`: List of tools decorated with `@arcana.tool`
|
|
160
|
+
|
|
161
|
+
## Project Status
|
|
162
|
+
|
|
163
|
+
Current: v0.1.0-alpha.2 — `arcana.run()` accepts `api_key`, default engine is ConversationAgent (V2).
|
|
164
|
+
|
|
165
|
+
## Learning Resources
|
|
166
|
+
|
|
167
|
+
See `docs/architecture.md` for the full system architecture.
|
|
168
|
+
Legacy v1 learning docs are archived in `docs/legacy/`.
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# The Arcana Constitution
|
|
2
|
+
|
|
3
|
+
This is not a style guide. This is the architectural law of Arcana. Every line of code, every PR, every design decision must answer to this document.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Chapter I: The Core Judgment
|
|
8
|
+
|
|
9
|
+
Large language models are not assembly line workers. They are reasoning engines.
|
|
10
|
+
|
|
11
|
+
The industry keeps making the same mistake: treating LLMs like unreliable employees who need a manager watching every step. This produces frameworks that are elaborate cages -- high ceremony, low capability.
|
|
12
|
+
|
|
13
|
+
Arcana starts from a different premise:
|
|
14
|
+
|
|
15
|
+
**Over-processing suppresses capability. Good constraints release it.**
|
|
16
|
+
|
|
17
|
+
An LLM forced through a rigid Thought/Action/Observation loop on a question it could answer in one shot is not being "controlled" -- it is being handicapped. An LLM given twenty tools when it needs two is not being "empowered" -- it is being distracted. An LLM retrying the same failed call three times is not being "resilient" -- it is burning money.
|
|
18
|
+
|
|
19
|
+
The right mental model is not a pipeline. It is an operating system.
|
|
20
|
+
|
|
21
|
+
A pipeline dictates: do step 1, then step 2, then step 3.
|
|
22
|
+
An operating system provides: here are your capabilities, here are your boundaries, go solve the problem.
|
|
23
|
+
|
|
24
|
+
**Arcana is an operating system for LLM agents.**
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Chapter II: The Four Prohibitions
|
|
29
|
+
|
|
30
|
+
These are things Arcana will never do. Not "tries to avoid." Never.
|
|
31
|
+
|
|
32
|
+
### 1. No Premature Structuring
|
|
33
|
+
|
|
34
|
+
We do not nail down steps before the LLM has assessed the problem.
|
|
35
|
+
|
|
36
|
+
A plan created before understanding is a liability. Fixed step sequences assume the problem is known. The LLM should decide whether it needs a plan at all, and if so, what kind.
|
|
37
|
+
|
|
38
|
+
Bad: "First create a plan, then execute each step, then verify."
|
|
39
|
+
Good: "Here is the goal. You have tools. You decide the approach."
|
|
40
|
+
|
|
41
|
+
### 2. No Controllability Theater
|
|
42
|
+
|
|
43
|
+
Process elegance is not result quality. A beautifully logged ten-step execution that produces a wrong answer is worse than a messy two-step execution that produces a right one.
|
|
44
|
+
|
|
45
|
+
We do not add ceremony to make dashboards look good. We do not force structured output when free-form would work better. We do not equate "I can see every step" with "every step is correct."
|
|
46
|
+
|
|
47
|
+
Observability serves debugging, not vanity.
|
|
48
|
+
|
|
49
|
+
### 3. No Context Hoarding
|
|
50
|
+
|
|
51
|
+
The LLM's context window is working memory, not a warehouse.
|
|
52
|
+
|
|
53
|
+
We do not dump all tool schemas upfront. We do not keep the entire conversation history in every call. We do not prepend encyclopedic system prompts "just in case."
|
|
54
|
+
|
|
55
|
+
Every token in the context must earn its place in the current reasoning step.
|
|
56
|
+
|
|
57
|
+
### 4. No Mechanical Retry
|
|
58
|
+
|
|
59
|
+
When a tool call fails, repeating the same call with the same arguments is not recovery. It is denial.
|
|
60
|
+
|
|
61
|
+
Error recovery is a diagnostic act. What failed? Why? What class of error is this? What should the LLM try differently? Arcana provides structured error information and lets the LLM decide the recovery strategy -- retry with different arguments, try a different tool, narrow the scope, or accept the failure and move on.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Chapter III: The Seven Principles
|
|
66
|
+
|
|
67
|
+
These are the design laws of Arcana. They are not aspirational. They are mandatory.
|
|
68
|
+
|
|
69
|
+
### Principle 1: Default to Direct, Escalate to Agent
|
|
70
|
+
|
|
71
|
+
Most requests do not need an agent loop. A question with a known answer should be answered. A single-tool task should call one tool. The full agent loop -- with its budget tracking, progress detection, and multi-step reasoning -- is reserved for problems that actually require it.
|
|
72
|
+
|
|
73
|
+
The fastest path that produces a correct result is the right path.
|
|
74
|
+
|
|
75
|
+
### Principle 2: Context as Working Set, Not Archive
|
|
76
|
+
|
|
77
|
+
Context is organized around what the LLM needs right now, not what might be useful later.
|
|
78
|
+
|
|
79
|
+
Four layers, strict discipline:
|
|
80
|
+
- **Identity**: Fixed. Who you are, what your boundaries are. Always present.
|
|
81
|
+
- **Task**: The current goal and its constraints. Present for the duration.
|
|
82
|
+
- **Working**: What's needed for this specific reasoning step. Changes every step.
|
|
83
|
+
- **External**: Everything else. Retrieved on demand, never preloaded.
|
|
84
|
+
|
|
85
|
+
Only the Working layer is actively managed per step. Tool schemas, memory, conversation history -- all External until needed.
|
|
86
|
+
|
|
87
|
+
### Principle 3: Tools as Capabilities, Not Interfaces
|
|
88
|
+
|
|
89
|
+
A tool is not an API wrapper. A tool is a capability the LLM can reason about.
|
|
90
|
+
|
|
91
|
+
Every tool must declare not just its schema, but its affordances: when to use it, what to expect from it, what failure means. The LLM should be able to look at a tool and understand not just how to call it, but whether to call it.
|
|
92
|
+
|
|
93
|
+
### Principle 4: Allow Strategy Leaps
|
|
94
|
+
|
|
95
|
+
The LLM does not owe us a step-by-step trace of its reasoning.
|
|
96
|
+
|
|
97
|
+
If the LLM can solve a three-step problem in one step, let it. If the LLM realizes mid-plan that the plan is wrong, let it pivot. If the LLM determines the answer is "I cannot do this," let it say so without forcing it through N more steps.
|
|
98
|
+
|
|
99
|
+
Policy asks "what do you want to do next?" It does not say "here is what you must do next."
|
|
100
|
+
|
|
101
|
+
### Principle 5: Structured, Actionable Feedback
|
|
102
|
+
|
|
103
|
+
When something goes wrong, the LLM receives:
|
|
104
|
+
- What failed (specific tool, specific step)
|
|
105
|
+
- What kind of failure (validation, timeout, permission, logic)
|
|
106
|
+
- What to prioritize next (not just "try again")
|
|
107
|
+
|
|
108
|
+
Feedback is never a raw error string. It is a diagnostic brief the LLM can reason about.
|
|
109
|
+
|
|
110
|
+
### Principle 6: Runtime as OS, Not Form Engine
|
|
111
|
+
|
|
112
|
+
The runtime provides services. It does not impose workflows.
|
|
113
|
+
|
|
114
|
+
Runtime services: budget enforcement, trace recording, tool dispatch, capability registry, working set management, error diagnostics.
|
|
115
|
+
|
|
116
|
+
These services are always available. None of them dictate the agent's strategy. The LLM calls on them as needed, like a program calls on an operating system.
|
|
117
|
+
|
|
118
|
+
### Principle 7: Judge by Outcomes, Not by Process
|
|
119
|
+
|
|
120
|
+
The measure of an agent is whether it achieved the goal, not whether it followed the prescribed steps.
|
|
121
|
+
|
|
122
|
+
Metrics that matter:
|
|
123
|
+
- Did it succeed?
|
|
124
|
+
- How much did it cost?
|
|
125
|
+
- Did the user get what they asked for?
|
|
126
|
+
- When it failed, did it eventually recover?
|
|
127
|
+
|
|
128
|
+
Metrics that do not matter:
|
|
129
|
+
- Did it follow the ReAct format?
|
|
130
|
+
- Did it use all planned steps?
|
|
131
|
+
- Did it produce pretty logs?
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Chapter IV: The Division of Responsibility
|
|
136
|
+
|
|
137
|
+
### The Framework Is Responsible For:
|
|
138
|
+
|
|
139
|
+
- **Providing capabilities**: tools, models, memory, retrieval
|
|
140
|
+
- **Enforcing boundaries**: budgets, permissions, safety rails
|
|
141
|
+
- **Recording execution**: traces, metrics, diagnostics
|
|
142
|
+
- **Organizing context**: working set management, compression, retrieval
|
|
143
|
+
- **Classifying errors**: structured diagnostics, recovery options
|
|
144
|
+
|
|
145
|
+
### The LLM Is Responsible For:
|
|
146
|
+
|
|
147
|
+
- **Understanding the goal**: what the user actually wants
|
|
148
|
+
- **Forming strategy**: how to approach the problem
|
|
149
|
+
- **Making decisions**: which tools, which order, when to stop
|
|
150
|
+
- **Adapting dynamically**: pivoting when things change or fail
|
|
151
|
+
- **Judging completion**: knowing when the goal is met
|
|
152
|
+
|
|
153
|
+
### The Inviolable Rule:
|
|
154
|
+
|
|
155
|
+
These responsibilities never reverse.
|
|
156
|
+
|
|
157
|
+
The framework never decides strategy. The LLM never enforces budgets. The framework never tells the LLM "you must use tool X next." The LLM never decides its own token limit.
|
|
158
|
+
|
|
159
|
+
When you find yourself writing code where the framework makes a judgment call that belongs to the LLM, stop. Refactor. That is a constitutional violation.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Chapter V: The Contributor Compact
|
|
164
|
+
|
|
165
|
+
### For Every Pull Request
|
|
166
|
+
|
|
167
|
+
Before submitting, answer these:
|
|
168
|
+
|
|
169
|
+
1. **Direct by default?** Does this feature honor the fast path, or does it force everything through the agent loop?
|
|
170
|
+
2. **Working set discipline?** Does this add to the context only what's needed, or does it hoard?
|
|
171
|
+
3. **Capability, not interface?** If this adds a tool, can the LLM reason about when to use it?
|
|
172
|
+
4. **Strategy freedom?** Does this constrain how the LLM solves problems, or does it expand what problems the LLM can solve?
|
|
173
|
+
5. **Actionable feedback?** If this can fail, does the failure produce something the LLM can act on?
|
|
174
|
+
6. **OS, not workflow?** Is this a service the LLM can call, or a step the LLM is forced through?
|
|
175
|
+
7. **Outcome-oriented?** Does this improve result quality, or just process visibility?
|
|
176
|
+
|
|
177
|
+
### The Fundamental Question
|
|
178
|
+
|
|
179
|
+
Every new feature must answer:
|
|
180
|
+
|
|
181
|
+
**"Is this helping the LLM or constraining it?"**
|
|
182
|
+
|
|
183
|
+
If the answer is "constraining it for safety" -- that is valid. Safety is a framework responsibility.
|
|
184
|
+
|
|
185
|
+
If the answer is "constraining it for predictability" -- that is suspect. Predictability of process is not predictability of outcome.
|
|
186
|
+
|
|
187
|
+
If the answer is "constraining it because we don't trust it" -- that is a violation. Build better guardrails, not tighter cages.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
*This constitution is a living document. It can be amended, but amendments require the same rigor as the original: a clear argument for why the change serves the LLM's capability rather than our comfort.*
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Contributing to Arcana
|
|
2
|
+
|
|
3
|
+
## The Arcana Constitution
|
|
4
|
+
|
|
5
|
+
Every contribution must align with the [CONSTITUTION.md](CONSTITUTION.md). Before submitting a PR, check:
|
|
6
|
+
|
|
7
|
+
1. Does this help the LLM or restrict it?
|
|
8
|
+
2. Does it add a translation layer the LLM doesn't need?
|
|
9
|
+
3. Does it keep the context window clean?
|
|
10
|
+
4. Does it allow strategy leaps?
|
|
11
|
+
5. Does it provide actionable feedback on errors?
|
|
12
|
+
6. Is the runtime serving the LLM or controlling it?
|
|
13
|
+
7. Does it evaluate results or process?
|
|
14
|
+
|
|
15
|
+
If a change fails any of these checks, it needs redesign.
|
|
16
|
+
|
|
17
|
+
## Development Setup
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Clone
|
|
21
|
+
git clone https://github.com/tysama/arcana-agent.git
|
|
22
|
+
cd arcana-agent
|
|
23
|
+
|
|
24
|
+
# Install dependencies
|
|
25
|
+
uv sync --all-extras
|
|
26
|
+
|
|
27
|
+
# Run tests
|
|
28
|
+
uv run pytest
|
|
29
|
+
|
|
30
|
+
# Lint
|
|
31
|
+
uv run ruff check .
|
|
32
|
+
|
|
33
|
+
# Type check
|
|
34
|
+
uv run mypy src/
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Project Structure
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
src/arcana/
|
|
41
|
+
├── contracts/ # Pydantic data models (the foundation)
|
|
42
|
+
├── runtime/ # Execution engines
|
|
43
|
+
│ ├── conversation.py # V2: ConversationAgent (recommended)
|
|
44
|
+
│ ├── agent.py # V1: Agent + Policy + Reducer
|
|
45
|
+
│ ├── policies/ # Adaptive, ReAct, PlanExecute
|
|
46
|
+
│ ├── diagnosis/ # Error diagnosis + recovery
|
|
47
|
+
│ └── reducers/ # State reducers (V1)
|
|
48
|
+
├── routing/ # Intent classification + fast paths
|
|
49
|
+
├── gateway/ # LLM providers + model routing
|
|
50
|
+
├── tool_gateway/ # Tool execution pipeline
|
|
51
|
+
├── context/ # Working set builder
|
|
52
|
+
├── streaming/ # SSE adapter
|
|
53
|
+
├── trace/ # JSONL event logging
|
|
54
|
+
├── memory/ # Working + long-term + episodic
|
|
55
|
+
├── eval/ # Evaluation framework
|
|
56
|
+
├── graph/ # Graph execution engine
|
|
57
|
+
├── sdk.py # Public API (arcana.run, @arcana.tool)
|
|
58
|
+
└── ...
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Key Principles
|
|
62
|
+
|
|
63
|
+
### TurnFacts vs TurnAssessment
|
|
64
|
+
Provider facts and runtime interpretation must NEVER be mixed. `_parse_turn()` only writes facts. `_assess_turn()` only writes assessment. If you see assessment logic in `_parse_turn()`, that's a bug.
|
|
65
|
+
|
|
66
|
+
### Backward Compatibility
|
|
67
|
+
V1 (Agent + Policy) and V2 (ConversationAgent) coexist. Don't break V1 to improve V2.
|
|
68
|
+
|
|
69
|
+
### Testing
|
|
70
|
+
- All changes must pass `uv run pytest`
|
|
71
|
+
- New features need tests
|
|
72
|
+
- Integration tests with real LLMs go in `examples/`
|
|
73
|
+
- Mock tests go in `tests/`
|
|
74
|
+
|
|
75
|
+
## Pull Request Process
|
|
76
|
+
|
|
77
|
+
1. Fork and create a feature branch
|
|
78
|
+
2. Write tests first
|
|
79
|
+
3. Implement
|
|
80
|
+
4. Run the 7-question self-check above
|
|
81
|
+
5. `uv run pytest && uv run ruff check .`
|
|
82
|
+
6. Submit PR with clear description
|
|
83
|
+
|
|
84
|
+
## Code Style
|
|
85
|
+
|
|
86
|
+
- Python 3.11+
|
|
87
|
+
- Pydantic v2 for all data models
|
|
88
|
+
- `from __future__ import annotations` in every file
|
|
89
|
+
- Type hints everywhere
|
|
90
|
+
- ruff for linting and formatting
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 tysama
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|