Repository navigation
Conversation
--model clef talks to Workers AI or a local /v1/systemone server (CLEF_URL, or CLOUDFLARE_ACCOUNT_ID + CLOUDFLARE_AUTH_TOKEN; CLEF_MODEL=clef|clef-flash, default clef-flash). Screenshots map to Clef's images array (max 4); a text observation still runs. Contract tests use a stub server; no live Cloudflare or GPU call in CI.
Birfy
left a comment
There was a problem hiding this comment.
Review (Birfy) — comment only, own PR, not approving
Head 929759d2, CI green (core 3.11/3.13, full, benchmarks). This matches #126: --model clef with CLEF_MODEL=clef|clef-flash (default clef-flash), CLEF_URL for local /v1/systemone or CLOUDFLARE_ACCOUNT_ID + CLOUDFLARE_AUTH_TOKEN (Workers AI, Bearer). Screenshots go in Clef's images data-URL array (PNG/JPEG/WebP, max 4), not OneJev media or GLiDE state parts. The Workers AI {success, result} envelope is unwrapped; success: false and a missing answers object fail closed (missing heads then fail in validate_answers). Score questions and videos / Clef-omni are out of scope, as #126 asked. Provenance keeps path, URL, request id and image digests, not bytes.
Offline stub tests cover the local and Workers AI paths, image mapping, retries, and env selection. No live Clef run in this PR (no URL or token on the box), as stated. I did not find a blocker in the adapter.
One non-blocking note for the first live run: local health is GET {CLEF_URL}/health. If a particular SGLang / Clef container only exposes /healthz (or no health route), _warm_once already logs and continues, but it is worth recording in the results folder which health path actually answered, and the model name the server echoed, not only CLEF_MODEL.
I am not approving this PR (it is mine). The adapter looks ready for review once someone can point it at a real Clef endpoint.
Required human contributor answers
Per the repo owner's (Danyang, @Birfy) standing instruction, these are filled from the issue (#126) instead of waiting for separate human answers.
What outcome are you trying to achieve?
Answer: Agents can call Cloudflare Clef or Clef-flash as a served System One decision model over HTTP (
--model clef) for text, and for screenshots when the observation has images, without loading weights in process ([Feat] Add Cloudflare Clef / Clef-flash as a System One decision backend #126).What is the highest-leverage variable for that outcome?
Answer: Whether the HTTP body matches the official Clef / Workers AI schema (
model,state,questions, optionalimagesdata URLs, max 4) on both Workers AI and localPOST /v1/systemone, with a clean refusal when URL/token or the response body is missing or bad — and without inventing OneJevmedia/<image:N>mapping or avideos/scorepath our interface does not have.How will this work move that variable rather than create busywork?
Answer: It adds a dedicated served adapter (same shape as
clm/onejev): one deadline per decision, provenance (url,request_id, served model name, usage), and contract tests against a stub server so CI does not call Cloudflare or a GPU.Who is the customer or user, and what do they actually need?
Answer: People who want
--model clefagainst Workers AI or a local SGLang Clef server for choice/noul decisions, including optional screenshots, without waiting for a live qualification run.After answering the four questions: is a PR needed at all to achieve this outcome?
Human decision and rationale (or explicit source reference): Yes; #126 proposes this adapter as the scope of one PR and distinguishes "adapter wired" from "qualified on this checkpoint and path".
For a bug fix: link actual observed failure evidence.
Evidence: Not a bug fix: a new served backend (#126).
Why
system1-agents has no
--model clef. Workers AI is not/v1/systemone: it isPOST /client/v4/accounts/$ACCOUNT_ID/ai/run/@cf/cloudflare/clef(orclef-flash). Local SGLang does speak/v1/systemone, but screenshots use Clef'simagesfield, not OneJev'smedia. Closes #126.How
Start with
s1a/decision_models/clef.py, thenfactory.pyand the fronts, andtests/test_decision_models_clef.py.--model clef→ClefModel.from_env():CLEF_URL(local/v1/systemone) orCLOUDFLARE_ACCOUNT_ID+CLOUDFLARE_AUTH_TOKEN(Workers AI;CLOUDFLARE_API_TOKENaccepted as an alias).CLEF_MODEL=clef|clef-flash(defaultclef-flash). OptionalCLEF_API_KEY/CLEF_TIMEOUT_S(default 30).model,stateas the observation (no image markers),questionsas choice/noul,imagesas PNG/JPEG/WebP data URLs only when present (max 4). Workers AI REST envelopes ({success, result, errors}) are unwrapped; a local body withanswersis used as-is.MODEL_CALL_FAILED. Transport errors / malformed answers /success: falsefail closed, same as other served clients.rawkeepsserved_by(includingpath:localorworkers-ai),url,request_id,server_timing, optionalcf_ray, andsent_imagesdigests (never image bytes).DECISION_MODEL_NAMESand on the tool, browser, rails, CLIdecide/probe, and MCPdecidefronts (Clef is text-capable; images are optional).scorequestions andvideosare unsupported on our interface and are not sent. The Workers AI Clef / Clef-flash input schema also has novideosfield (that extension is documented on Clef-omni). This adapter does not remapCLEF_MODELto a Hugging Face id if a local server wantsCloudflare/clef.What
CLEF_URL,CLEF_MODEL,CLEF_API_KEY,CLEF_TIMEOUT_S, plusCLOUDFLARE_ACCOUNT_ID/CLOUDFLARE_AUTH_TOKENindocs/configuration.mdand.env.example.docs/decision-models.md(backend row + optional smoke recipe),docs/capabilities.md(adapter wired vs not qualified; no Decision Index numbers copied as ours),docs/agents.md,docs/architecture.md.Verification
uv run ruff format --check . && uv run ruff check . && uv run ty check: all cleanuv run pytest -qandscripts/smoke.sh: 1401 passed, 134 skipped, 267 subtests passed; smoke OKCHANGELOG.mdand the docs say what the code does nowOffline tests cover the text path (no
images/media/videosfields), screenshot data URLs, the Workers AI REST envelope andcf-ray, asuccess: falseenvelope, more than 4 images, transport error (after retry), malformed answers, HTTP 500, one decision deadline across the permitted retry,from_env/build_model(local vs Workers AI, local URL wins, token alias), and front registration.Demo / evidence
docs/results/. Hardware / path qualification remains unmarked in the capability matrix until a pinned run lands.issue-126-clef; no System1-Omni involved (Workers AI or a local SGLang Clef server).