Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ SESSION_SECRET # Express session encryption (no fallback in prod)
INTERNAL_API_SECRET # Express→Python shared secret (start-dev.sh generates a per-run value)
DATABASE_URL # PostgreSQL connection string
XAI_API_KEY # Grok energy provider
DEEPSEEK_API_KEY # DeepSeek V4 Flash/Pro; also used by standalone a0
A0_PROVIDER # Optional standalone provider id (e.g. deepseek-pro)
DEEPSEEK_API_KEY # DeepSeek V4.1 Flash; also used by standalone a0
A0_PROVIDER # Optional standalone provider id; deepseek is canonical
STRIPE_SECRET_KEY # Stripe billing
STRIPE_WEBHOOK_SECRET # Stripe webhook validation
ADMIN_USER_ID # User ID allowed to write prompt contexts
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## The Agent

ZFAE (`a0(zeta fun alpha echo)`) is the single persistent agent running on the instrument. Large language models (GPT-5 mini, Gemini 2.5 Flash, Claude Sonnet 4.5, Grok 4 Fast, DeepSeek V4) are treated as **energy providers** — they supply computational energy for each response but are not the agent itself.
ZFAE (`a0(zeta fun alpha echo)`) is the single persistent agent running on the instrument. Large language models (GPT-5 mini, Gemini 2.5 Flash, Claude Sonnet 4.5, Grok 4 Fast, DeepSeek V4.1 Flash) are treated as **energy providers** — they supply computational energy for each response but are not the agent itself.

Sub-agents (`a0(zeta{n})`) can be spawned to fork the PCNA instance, execute in parallel, and merge results back into the primary agent.

Expand Down Expand Up @@ -90,14 +90,17 @@ In development `scripts/start-dev.sh` generates a shared `INTERNAL_API_SECRET` a

The standalone `run.sh` runtime reads the same `python/config/providers.json`
registry as the FastAPI service. With a DeepSeek key present it auto-selects
V4 Flash through the generic `openai-compatible` adapter. Pin V4 Pro explicitly:
V4.1 Flash through the generic `openai-compatible` adapter:

```bash
export DEEPSEEK_API_KEY="..."
export A0_PROVIDER=deepseek-pro # omit for deepseek-v4-flash
printf '%s\n' '{"task_id":"ds1","input":{"text":"hello"},"tools_allowed":["none"],"mode":"analyze","hmmm":["direct model turn"]}' | ./run.sh
```

The canonical API model is `deepseek-flash`. The retired provider choice
`A0_PROVIDER=deepseek-pro` remains a hidden compatibility alias and resolves to
the same V4.1 Flash route; it no longer represents a higher-capability tier.

Provider configuration contains only the credential environment-variable name;
keys remain in the process environment and are never written to source.

Expand Down Expand Up @@ -133,7 +136,7 @@ npx playwright test
| `ANTHROPIC_API_KEY` | Claude Sonnet 4.5 |
| `GEMINI_API_KEY` | Gemini 2.5 Flash |
| `OPENAI_API_KEY` | GPT-5 mini |
| `DEEPSEEK_API_KEY` | DeepSeek V4 Flash/Pro through the OpenAI-compatible adapter |
| `DEEPSEEK_API_KEY` | DeepSeek V4.1 Flash through the OpenAI-compatible adapter |
| `STRIPE_SECRET_KEY` | Stripe (donations + EDCMbone explainer) |
| `STRIPE_PUBLISHABLE_KEY` | Stripe embedded checkout |
| `STRIPE_WEBHOOK_SECRET` | Stripe webhook HMAC |
Expand Down
14 changes: 11 additions & 3 deletions a0/adapters/open_comp_adap_v0.0.0alpha.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 100:47 0:0 2:0
# 102:53 0:0 2:0
"""Synchronous standalone adapter for registry-defined OpenAI-compatible APIs."""
from __future__ import annotations

Expand Down Expand Up @@ -47,6 +47,12 @@
# then: the adapter raises the effective effort to that configured floor before transport
# class: correctness
# since: 2026-09-10
#
# id: a0_openai_compatible_explicit_none_reasoning
# given: a compatible provider declares that reasoning effort none must be sent explicitly
# then: standalone Responses calls carry reasoning.effort=none rather than falling back to the provider default
# class: correctness
# since: 2026-09-10
# === END CONTRACTS ===

import os
Expand Down Expand Up @@ -130,7 +136,9 @@ def complete(self, messages: List[Message], **kwargs: Any) -> Dict[str, Any]:
)
if supports_store:
request["store"] = bool(kwargs.get("store", False))
if effort and effort != "none":
if effort and (
effort != "none" or self.spec.get("explicit_none_reasoning")
):
request["reasoning"] = {"effort": effort}
response = self._client.responses.create(**request)
text = _response_text(response)
Expand Down Expand Up @@ -162,4 +170,4 @@ def complete(self, messages: List[Message], **kwargs: Any) -> Dict[str, Any]:
},
"subagents_used": [],
}
# 100:47 0:0 2:0
# 102:53 0:0 2:0
30 changes: 26 additions & 4 deletions a0/prov_regi_v0.0.0alpha.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 36:29 0:0 1:0
# 55:30 0:0 1:0
"""Read standalone a0 model adapters from the canonical provider registry."""
from __future__ import annotations

Expand Down Expand Up @@ -26,7 +26,7 @@
# === CONTRACTS ===
# id: a0_provider_selection
# given: optional A0_PROVIDER, canonical provider registry data, and process credentials
# then: an explicit compatible provider resolves or fails closed while an unset choice may auto-select only a configured a0_default provider
# then: an explicit compatible provider resolves or fails closed, deprecated provider aliases resolve to their canonical provider, and an unset choice may auto-select only a configured a0_default provider
# class: correctness
# since: 2026-09-07
# === END CONTRACTS ===
Expand All @@ -49,6 +49,27 @@ def _is_openai_compatible(spec: dict[str, Any]) -> bool:
return spec.get("adapter") == "openai-compatible" or spec.get("vendor") == "openai"


def _resolve_alias(
providers: dict[str, dict[str, Any]],
provider_id: str,
) -> tuple[str, dict[str, Any]]:
"""Resolve one registry-declared provider alias without provider literals."""
spec = providers[provider_id]
canonical_id = str(spec.get("deprecated_alias_for") or "").strip()
if not canonical_id:
return provider_id, spec
canonical = providers.get(canonical_id)
if canonical is None:
raise ValueError(
f"A0_PROVIDER {provider_id!r} aliases missing provider {canonical_id!r}"
)
if canonical.get("deprecated_alias_for"):
raise ValueError(
f"A0_PROVIDER {provider_id!r} has a chained provider alias"
)
return canonical_id, canonical


def resolve_openai_compatible_provider(
provider_id: str | None = None,
) -> tuple[str, dict[str, Any]] | None:
Expand All @@ -59,11 +80,12 @@ def resolve_openai_compatible_provider(
spec = providers.get(explicit)
if spec is None:
raise ValueError(f"Unknown A0_PROVIDER: {explicit!r}")
canonical_id, spec = _resolve_alias(providers, explicit)
if not _is_openai_compatible(spec):
raise ValueError(
f"A0_PROVIDER {explicit!r} does not use the openai-compatible adapter"
)
return explicit, spec
return canonical_id, spec

for candidate, spec in providers.items():
api_key_env = str(spec.get("api_key_env") or "")
Expand All @@ -75,4 +97,4 @@ def resolve_openai_compatible_provider(
):
return candidate, spec
return None
# 36:29 0:0 1:0
# 55:30 0:0 1:0
30 changes: 17 additions & 13 deletions python/config/pricing.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": "2026-09-07.a0.pricing.v2",
"prices_as_of": "2026-09-07",
"version": "2026-09-10.a0.pricing.v3",
"prices_as_of": "2026-09-10",
"_doc": {
"schema": "providers.<id>.models is a list of {id, context_window, input_per_1m, output_per_1m, cached_input_per_1m?, cache_write_per_1m?, supports_vision?, supports_thinking?, note?} entries. All prices are USD per 1,000,000 tokens.",
"schema": "providers.<id>.models is a list of {id, context_window, max_output_tokens?, input_per_1m, output_per_1m, cached_input_per_1m?, cache_write_per_1m?, supports_vision?, supports_thinking?, note?} entries. All prices are USD per 1,000,000 tokens.",
"source-of-truth": "Boot source-of-truth for per-model pricing. estimate_cost(provider_id, ..., model=<id>) consults this file first and uses per-model rates; without a model arg, falls back to the provider flagship rate from providers.json. Hydrates each ws_modules.route_config.available_models list on first boot and on POST /api/energy/refresh-pricing/{provider_id}.",
"naming": "Model ids are the slugs the provider's API accepts. Keep in sync with providers.json presets section so optimizer presets and per-model pricing line up.",
"live-refresh": "POST /api/energy/refresh-pricing/{provider_id} re-reads this file from disk and re-hydrates the seed's available_models. Live HTML extraction from pricing_url is a future phase; for now admins update this file in repo, redeploy, then refresh."
Expand Down Expand Up @@ -187,27 +187,31 @@
"pricing_url": "https://api-docs.deepseek.com/quick_start/pricing/",
"models": [
{
"id": "deepseek-v4-flash",
"id": "deepseek-flash",
"context_window": 1000000,
"input_per_1m": 0.44,
"output_per_1m": 1.32,
"cached_input_per_1m": 0.014,
"max_output_tokens": 384000,
"input_per_1m": 0.3,
"output_per_1m": 1.2,
"cached_input_per_1m": 0.006,
"supports_thinking": true,
"note": "Official peak rates; off-peak rates are lower."
"supports_vision": true,
"note": "DeepSeek V4.1 Flash official peak rates; off-peak rates are half."
}
]
},
"deepseek-pro": {
"pricing_url": "https://api-docs.deepseek.com/quick_start/pricing/",
"models": [
{
"id": "deepseek-v4-pro",
"id": "deepseek-flash",
"context_window": 1000000,
"input_per_1m": 1.32,
"output_per_1m": 3.96,
"cached_input_per_1m": 0.044,
"max_output_tokens": 384000,
"input_per_1m": 0.3,
"output_per_1m": 1.2,
"cached_input_per_1m": 0.006,
"supports_thinking": true,
"note": "Official peak rates; off-peak rates are lower."
"supports_vision": true,
"note": "Compatibility pricing for the retired deepseek-pro provider id; routes to DeepSeek V4.1 Flash."
}
]
}
Expand Down
Loading