DEV-1586: pre-encoded mode for the SLayer claude_sdk agents - #55
Conversation
Add a read-only "pre-encoded" flavor to the four SLayer claude_sdk OTF
agents (claude_sdk_otf, _ainteract, v0+v1) so they run against an
ALREADY-encoded SLayer datasource instead of encoding KB on the fly,
mirroring the pydantic_ai committed-reference consumer.
Factored, not copy-pasted (per the brief): a shared agents/_pre_encoded.py
(source-root selection, benchmark-aware per-task storage resolver with
HARD-8 deleted-KB masking via build_task_variant_storage, fail-clear on a
missing reference / embeddings, write-tool filtering, slayer_setup
derivation) and a shared agents/_pre_encoded_prompts.py (one introspect-only
prompt per eval_mode, reused by v0+v1; the frozen on-the-fly prompts are
untouched). Each agent gained a pre_encoded_source param that branches
storage, tool surface (drops create_model/edit_model/save_memory/
validate_models + the normalize-write hook), prompt, and disallowed_tools.
User-facing: new --pre-encoded-models {otf,custom} on `bird-interact-cloud
submit` and the local CLI; the retired --slayer-setup is dropped from both
(slayer_setup is now DERIVED from the flag and kept internally because cloud
routing/fingerprint/merge consume it). otf -> slayer_models_otf/<benchmark>/
<db>; custom -> slayer_models/<db>. The flag is gated to the claude_sdk
SLayer frameworks and to query-mode slayer.
Cloud: source-aware artifact upload/download/presence routing; job-args +
resubmit thread pre_encoded_source (legacy pre-encoded manifests default to
custom); provenance recorded in run_metadata / SubmissionConfig / collation;
upload-back merge stays gated to otf_encode+on-the-fly so read-only runs
skip it.
Tooling: scripts/build_otf_references.py batch-builds the LLM-encoded
references for a whole benchmark (the consumer fails clear pointing at it).
Tests: tests/test_dev1586_pre_encoded.py (mechanical contracts only) plus
migration of the slayer-setup CLI tests to the new flag. Also fixes a
pre-existing CWD leak of embeddings.db in test_one_shot_run.py via an
autouse cwd-isolation fixture.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughIntroduces a read-only "pre-encoded" SLayer mode (DEV-1586) for four Claude SDK OTF agent variants. Replaces the retired ChangesPre-encoded SLayer mode (DEV-1586)
Sequence Diagram(s)sequenceDiagram
participant CLI as run.py CLI
participant Validator as _validate_slayer_setup
participant Runner as make_runner
participant Agent as ClaudeSDKOtfAgent
participant PreEncoded as _pre_encoded
participant SLayerMCP as SLayer MCP Server
CLI->>CLI: parse --pre-encoded-models otf → pre_encoded_source="otf"
CLI->>CLI: derive_slayer_setup("otf") → slayer_setup="pre-encoded"
CLI->>Validator: _validate_slayer_setup(framework, query_mode, slayer_setup, pre_encoded_source)
Validator-->>CLI: ok
CLI->>Runner: run_evaluation(..., pre_encoded_source="otf", slayer_setup="pre-encoded")
Runner->>Agent: __init__(..., pre_encoded_source="otf", slayer_setup="pre-encoded")
Agent->>Agent: validate_pre_encoded_source("otf")
Note over Agent: run_task per DB
Agent->>PreEncoded: resolve_pre_encoded_storage_dir(db, task_data, benchmark, "otf")
PreEncoded->>PreEncoded: _assert_reference_present("otf", ref_dir)
PreEncoded-->>Agent: (slayer_storage_dir, deleted_kb_ids)
Agent->>Agent: strip_write_slayer_tools(SLAYER_MCP_TOOLS)
Agent->>Agent: use SLAYER_PRE_ENCODED_ONE_SHOT prompt
Agent->>SLayerMCP: list_datasources, search, inspect_model, query (read-only)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
Retire the --slayer-setup flag from all README examples (on-the-fly is now the default for slayer mode) and add a dedicated "Pre-encoded mode" section covering the otf/custom sources, the introspection-only tool surface, the fail-clear-if-missing contract + scripts/build_otf_references.py batch builder, and the cloud download/no-upload-back behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
_maybe_force_wipe_otf gated only on framework, so a pre-encoded run with --otf-rebuild would purge the OTF cache/reference for the selected DBs — and for --pre-encoded-models otf that reference IS the read-only agent's input, which it cannot rebuild. Thread pre_encoded_source through and no-op the wipe whenever it is set. Regression test added. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… r2) - Cloud submit now fails fast for a claude_sdk pre-encoded run whose reference lacks a usable embeddings.db, mirroring the runtime ingest_on_startup=False guard so a doomed run aborts before the cluster spins up. Gated on pre_encoded_source (the committed-reference pydantic path ingests on startup and needs no pre-built embeddings). - Drop the retired --slayer-setup on-the-fly from scripts/run_haiku_slayer.sh and scripts/run_three_way.sh (on-the-fly is now the slayer default). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
Adds a read-only pre-encoded flavor to the four SLayer
claude_sdkOTF agents (claude_sdk_otf,claude_sdk_otf_ainteract, ×v0/v1) so they run against an already-encoded SLayer datasource instead of encoding KB on the fly — mirroring thepydantic_aicommitted-reference consumer.Selected by a new flag
--pre-encoded-models {otf,custom}:otf(default sense) → the encoding-agent output atslayer_models_otf/<benchmark>/<db>custom→ the hand-curatedslayer_models/<db>In pre-encoded mode the agents have no model-mutation tools (
create_model/edit_model/save_memory/validate_modelsdropped) — introspection only.Factoring (no copy-pasted "zoo")
Per the brief, the four agents are factored rather than duplicated:
agents/_pre_encoded.py— source-root selection, a benchmark-aware per-task storage resolver (HARD-8 deleted-KB masking viabuild_task_variant_storage, threadingmini_interact_root/db_rootcorrectly for non-mini benchmarks), fail-clear on a missing reference /embeddings.db, write-tool filtering,slayer_setupderivation.agents/_pre_encoded_prompts.py— one introspect-only prompt per eval_mode, reused by v0+v1. The frozen on-the-fly prompts are untouched.pre_encoded_sourceparam that branches storage, tool surface (v0 whitelist + v1MAIN_TOOLS/subagent), prompt, hooks, anddisallowed_tools.Flag retirement & cloud wiring
--slayer-setupis retired from both user-facing CLIs; the internalslayer_setupis derived from--pre-encoded-modelsand kept because cloud artifact routing / fingerprinting / merge consume it. The flag is gated to the claude_sdk SLayer frameworks and to--query-mode slayer.pre_encoded_source(legacy pre-encoded manifests default tocustom); provenance recorded inrun_metadata/SubmissionConfig/ collation; upload-back merge stays gated tootf_encode + on-the-flyso read-only runs skip it.Tooling
scripts/build_otf_references.pybatch-builds the LLM-encoded references for a whole benchmark (the consumer fails clear pointing at it).Tests
tests/test_dev1586_pre_encoded.py(mechanical contracts only, per project rule) + migration of the slayer-setup CLI tests to the new flag. Also fixes a pre-existing CWD leak ofembeddings.dbintest_one_shot_run.pyvia an autouse cwd-isolation fixture. Full non-integration suite: 3341 passed.Plan and tests were reviewed by Codex (two rounds); all findings folded in.
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
claude_sdkusing--pre-encoded-models {otf,custom}(including pre-encoded a-interact flows).Documentation
--pre-encoded-modelsand reflect that slayer mode now encodes on-the-fly by default.Bug Fixes
pre_encoded_sourcein run metadata.Chores
--slayer-setupCLI flag in favor of--pre-encoded-models.