Repository navigation
dagql: recipe ID DAG dedupe, directive views - #13776
Conversation
198cd7c to
ae1848e
Compare
@vito I haven't read the code or the details yet, but in terms of the explanation here this doesn't sound correct at all and like it might be re-inventing something that already exists. Secret handles are given a handle derived from the content of the secret. Sessions can get cache-hits between each other even when secrets are used provided they are using secrets that are equivalent. More generally, this is just the same caching logic of everything else in the dagql cache: any two things that have any two digests in common are considered equivalent.
|
|
@sipsma oh yeah I'm already dropping that (hence the note above it) - felt weird from the start and it turns out it was to support a variant of the same problem that exposing currentWorkspace to modules ran into. Basically the fix is to make it so Query.llm doesn't inherit the workspace, and make you use withWorkspace to set one that your function accepts as an argument, which fixes the caching behavior |
e9845d6 to
fe37ad3
Compare
fe37ad3 to
bab9aed
Compare
Recipe IDs round-tripped through ResultCall frames without memoization in either direction, so a shared sub-DAG — a base object reached via a long receiver chain and referenced by many args — was rebuilt once per path, unrolling the DAG into a tree. Resuming a long agent session, whose accumulated state is one large heavily shared ID DAG, blew up to ~10^8 frames and tens of GB, OOMing the host; fixing expansion alone surfaced the same blowup on the reconstruction side at ~2.6e8 objects. Thread a per-decode memo through both directions: expansion keys on recipe digest, reconstruction on sharedResultID for by-ID refs and on *ResultCall identity for inline frames. IDs are content-addressed, immutable, and acyclic, and frames are frozen provenance cloned before any mutation, so sharing one node per distinct sub-ID is safe and collapses the tree back into a DAG. Signed-off-by: Alex Suraci <[email protected]>
The recipe expansion and reconstruction fixes made frames store as compact shared DAGs, but clone() still deep-copied them: a shared node reached via N paths was re-expanded once per path, unrolling the DAG back into a tree. Cloning one large shared frame exploded to ~3.3e8 objects and ~28GB before the engine OOMed, captured live by the memory recorder mid-spike. Memoize clone() by the source *ResultCall (the only shared join point) so each distinct frame is cloned once and reused. The copy stays fully independent of the original (distinct nodes); only sharing within one clone is preserved, which is safe because frames are frozen provenance, never mutated in place below the top-level spine. The now-unused Arg/Literal/Ref clone wrappers are dropped in favor of the memo-threading cloneWith. Signed-off-by: Alex Suraci <[email protected]>
Directives could not be gated by API version, so a directive introduced for a new API surface would appear in the schema served to older clients. Give DirectiveSpec a ViewFilter and honour it when installing, matching how fields and objects are already gated. Signed-off-by: Alex Suraci <[email protected]>
bab9aed to
6030fc3
Compare
Engine internals the agent work exposed, split out so they can be reviewed as ordinary dagql changes.
Recipe ID DAG round-trip. Recipe IDs round-tripped through
ResultCallframes with no memoization in either direction, so a shared sub-DAG — a base object reached via a long receiver chain and referenced by many args — was rebuilt once per path, unrolling the DAG into a tree. Resuming a long agent session, whose accumulated state is one large heavily shared ID DAG, blew up to ~10^8 frames and tens of GB and OOMed the host; fixing expansion alone surfaced the same blowup on the reconstruction side at ~2.6e8 objects, and then again inclone()at ~3.3e8 objects. All three now memoize, keyed by recipe digest,sharedResultID/frame identity, and source frame respectively. IDs are content-addressed, immutable and acyclic, and frames are frozen provenance cloned before mutation, so sharing one node per distinct sub-ID is safe.Directive views.
DirectiveSpecgains aViewFilter, honoured at install time, so a directive introduced for a new API surface no longer appears in the schema served to older clients — matching how fields and objects are already gated.