Skip to content

Decouple execution history and feature-gate response caching - #134

Open
arthurianresolve wants to merge 76 commits into
krypticmouse:mainfrom
arthurianresolve:fix-optional-response-cache
Open

arthurianresolve wants to merge 76 commits into
krypticmouse:mainfrom
arthurianresolve:fix-optional-response-cache

Conversation

@arthurianresolve

@arthurianresolve arthurianresolve commented Nov 10, 2026 •

Copy link
Copy Markdown

Summary of Fix

Includes resolved #121, #103 and #133 (with #131/#132). Merge the runtime/rendering/LM PRs before this PR.

  • Integrate configuration overrides with independent history and optional caching. Give config copies fresh history while retaining injected clients for generation-only changes; validate cache requests and feature-gate cache initialization in copy_with.

  • Compose LM/default/explicit-call scopes with history scopes in either wrapper order, preserving predictor discovery and concurrent override isolation.

  • Record bounded execution history independently of response caching, including cache hits, tool calls, provider and parse failures, and cancellations.

  • Add global and per-LM inspection, automatic predictor history, and parent-module tracking through Module::with_history. Configure and clear each store independently; LM clones share their store, while replacing a client starts fresh history and cache state.

  • Store input messages, redacted LM configuration, raw responses, parsed outputs, usage, timestamps, call IDs, caller paths, and trace-format events/errors. Attach the interpreter's parsed result to the same record visible at each history level. Cache hits report zero newly consumed tokens.

  • Add a default-on cache Cargo feature for foyer, tempfile, response-cache exports, and LM::cache_handler. Reject explicit cache requests when the feature is absent, both during construction and after configuration changes.

  • Remove unused Rayon and its unused transitive dependencies. Preserve the existing data feature and default data-loading/cache availability; JSON/JSONL loading and execution history remain available without either feature.

  • Document history inspection, module scopes, API migration, and the supported feature combinations.

  • Add structured optimizer compilation, batch/rollout progress and budget events, plus module/evaluator/parse/constraint spans. Emit full prompts, responses and intermediate choices only through the opt-in dsrs::content=debug target.

  • Preserve typed completion, tool, rollout, cache and data-loading causes through outer errors. Report HTTP data-loading status before parsing; retain mapper row context and the original cause.

  • Integrate the current trace capture/JSONL/replay APIs with invocation history and document their different lifecycles. Verify a composed flow and parse-failure behavior through the active APIs.

  • Add a first-class InteractionStore with a versioned, locked JSONL implementation. Persist raw/parsed invocation revisions and complete captured traces, expose call IDs, and correlate invocations with their trace IDs.

  • Compose persistence through with_interaction_store, independently of cache or bounded history retention. Preserve typed storage failures and recover an interrupted final append without accepting corrupt complete records.

Fixes #55
Fixes #70
Fixes #74
Fixes #56
Fixes #67
Fixes #68

Why

In-memory history and trace serialization alone did not supply a persistent interaction store. The new integration journals calls and traces with durable revisions and stable invocation IDs, including when history capacity is zero. Scoped persistence waits until completion to return storage errors; spawned tasks establish their own scope. See docs/interaction-storage.md.

History previously read a window maintained by response-cache insertions. Disabling caching therefore removed history, and inserting cache entries could appear to represent executions. Moving invocation records into independent stores makes history reflect actual LM calls and allows response-cache storage to be compiled out.

The existing data feature already gates Arrow, Parquet, Hugging Face and CSV. The remaining cache dependencies were unconditional, and Rayon had no source consumers. With this change, --no-default-features excludes those stacks from the normal dependency graph. HTTP support remains required for LM providers and JSON/JSONL loading; tempfile remains a development dependency for tests.

LM::inspect_history now returns Vec<HistoryEntry> instead of Vec<CacheEntry>, and ResponseCache::get_history is removed. Predictors collect history automatically; parent modules opt in with with_history, and spawned tasks must establish their own scopes. History complements trace capture and replay using the existing event/error types. Pure trace replay does not invoke the LM and does not add history. Pricing is unavailable, so cost remains None; failed or cancelled calls retain unknown usage as None.

Related work

Testing

  • Final integrated cache-enabled release checks: 61 tests passed using --no-default-features --features cache (three live tests excluded from this offline run). This covers invocation history, persistent storage, tool-loop limits, native/scalar output and trace/history parity.

  • The current integrated minimal-feature suite passed 68 tests across compiler transformations, structural edits, persistent storage, typed special fields, and trace/history behavior (two live tests skipped in the offline run; both passed separately).

  • Storage regressions include six simultaneous writers using independent handles, revision replacement, torn-append recovery, corrupt-row rejection, scoped error causes, call-ID propagation and captured-trace round trips.

  • The resolved stack at 2b4590f0174dc05582347b8da75b6b58fbce9ca0 passed 209 tests with --no-default-features and 247 with default data/cache features (2 live tests ignored per offline run). These are focused library and integration suites, not the full workspace test suite. Later ancestry-only integration merges preserve the validated source trees.

  • Three observability regressions verify progress/budget events, typed rollout causes, parent module spans and opt-in content logging.

  • Two trace/history regressions exercise real composed predictions, JSONL round trips, strict replay and parse-failure parity. Two data-error regressions retain concrete JSON/mapper causes and local HTTP 429 status.

  • History/configuration suites cover cache on/off, copies and replacement-client isolation, both LM/history wrapper orders, cancellation, parse failures and concurrency.

  • The normal --no-default-features dependency graph excludes foyer, tempfile, Rayon, Arrow, Parquet, Hugging Face and CSV; tests retain tempfile as a development dependency. No dependency versions were updated.

  • The final integrated live matrix also passed all nine example task signatures against temporary Ollama/llama3.2; this is separate from the offline suites.

  • git diff --check — passed.

AI Disclosure

  • OpenAI Codex assisted with implementation, tests, and PR drafting.
  • all fixes and drafts have been human-architected, human-directed and human-reviewed before publication of PR requests.

…-structured-output

# Conflicts:
#	crates/dspy-rs/src/core/lm/mod.rs
#	crates/dspy-rs/src/trace/span.rs
@mintlify

mintlify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 693a1ae.

Approve preview

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant