Skip to content

feat(templates,examples): add 8-slot context pruning policy and Genkit example - #59

Merged
ghchinoy merged 1 commit into
mainfrom
feat/agent-context-pruning
Nov 10, 2026
Merged

ghchinoy merged 1 commit into
mainfrom
feat/agent-context-pruning

Conversation

@jigyasujuneja

Copy link
Copy Markdown
Collaborator

Summary

Splits the 8-slot trajectory context pruning policy and token-budget knapsack example out of PR #36 so each PR has a clean single responsibility and zero unwired code in pkg/decisionindex:

  1. Canonical Starter Template + .examples.json Sidecar:
    • templates/agent_context_pruning.json.tmpl: evaluates up to 8 candidate trajectory blocks (b0..b7) across full, stub, and drop in a single dgem pass with schema-nested layout: "document_first" and isolate: "auto".
    • templates/agent_context_pruning.examples.json: provides typical (unambiguous: true with validated expected_answers), edge, and minimal variable sets that round-trip cleanly through CoerceJSONVariableStrings.
  2. Runnable Genkit Example (examples/genkit-context-pruning/):
    • Executes agent_context_pruning.json.tmpl via dgemgenkit.DecideWithTemplate and solves the exact Pareto-filtered Multiple-Choice Knapsack (SelectContextPruningActions) subject to TokenBudget and Pinned block constraints.

Verification

  • env -u DGEM_VERTEX_URL go vet ./...
  • env -u DGEM_VERTEX_URL go test -race ./cmd/... ./pkg/...
  • env -u DGEM_VERTEX_URL go -C examples vet ./genkit-context-pruning/...
  • env -u DGEM_VERTEX_URL go -C examples test -race -v ./genkit-context-pruning/...

…t example

- Add canonical templates/agent_context_pruning.json.tmpl and companion
  templates/agent_context_pruning.examples.json passing TestAllShippedTemplatesRenderAndValidate
  and SampleVars JSON coercion round-trips.
- Register fallback sample variables (task_goal, turn_index, token_budget, blocks)
  in cmd/serve.go.
- Add runnable examples/genkit-context-pruning/ executing agent_context_pruning.json.tmpl
  via Genkit SystemOne and solving the exact Pareto-filtered Multiple-Choice Knapsack
  under hard token-budget and pinned-block constraints.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants