Skip to content

docs: search plumbing for agent autoresearch loops - #279

Merged
AregGevorgyan merged 1 commit into
mainfrom
docs/search-plumbing-docs
Aug 8, 2026
Merged

docs: search plumbing for agent autoresearch loops#279
AregGevorgyan merged 1 commit into
mainfrom
docs/search-plumbing-docs

Conversation

@AregGevorgyan

@AregGevorgyan AregGevorgyan commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • New mdBook overview search-plumbing.md linking budgets, batch, compact envelopes, claim graphs, and certificate coverage.
  • Sphinx api/workload.rst plus DerivedResult.to_dict / BudgetExceededError / context(budget=…) entries.
  • Cross-links from intro, getting-started, python-api, claim-graphs, batch, budgets, derivations, and README.

Test plan

  • mdbook build docs/mdbook
  • sphinx-build -W docs/sphinx …
  • Docs CI green

Made with Cursor

Summary by CodeRabbit

  • Documentation
    • Added guides for autoresearch and agent-driven search loops.
    • Documented budgets, cancellation, batch and streaming evaluation, and error handling.
    • Added guidance for compact, versioned result serialization and verification status.
    • Expanded API documentation for workload processing, budget controls, result schemas, and certificate checks.
    • Added examples for candidate evaluation, research claims, and handling budget or verification outcomes.
    • Improved navigation and cross-links across related guides.

Add an overview chapter tying budgets, batch APIs, compact DerivedResult
envelopes, and claim graphs together; expand Sphinx/README/getting-started
with the same surface.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds documentation for workload APIs, result serialization, budgets, batch evaluation, certificate handling, and autoresearch or agent-loop workflows across Sphinx, mdBook, the README, and the changelog.

Changes

Search Plumbing Documentation

Layer / File(s) Summary
Workload and result API documentation
docs/sphinx/api/workload.rst, docs/sphinx/api/core.rst, docs/sphinx/api/errors.rst, docs/sphinx/index.rst
Documents workload helpers, batch APIs, budget errors, DerivedResult serialization, expanded context options, and schema constants.
Agent-loop workflows
README.md, docs/mdbook/src/search-plumbing.md, docs/mdbook/src/batch.md, docs/mdbook/src/getting-started.md, docs/mdbook/src/intro.md, docs/mdbook/src/python-api.md
Documents bounded search loops, batch integration, compact logs, verification handling, and research-session capture.
Guide navigation and cross-links
docs/mdbook/src/SUMMARY.md, docs/mdbook/src/budgets.md, docs/mdbook/src/claim-graphs.md, docs/mdbook/src/derivations.md, CHANGELOG.md
Adds navigation entries and links among search-plumbing, budget, batch, derivation, claim-graph, certificate, and error documentation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary documentation change for search plumbing used by agent autoresearch loops.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/search-plumbing-docs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/mdbook/src/intro.md`:
- Around line 17-23: Update the “Stateless by design” determinism claim to
distinguish reproducibility from strict determinism: explain that explicit
context improves reproducibility, step and seed controls can be deterministic,
and wall-clock budgets such as wall_ms remain best-effort because they depend on
machine load and scheduling.

In `@docs/mdbook/src/search-plumbing.md`:
- Around line 39-43: Update the failure-handling bullets in search-plumbing.md
to distinguish direct-call handling from integrate_many’s batch-result handling:
BudgetExceededError from batch candidates is represented as BatchItem(ok=False,
error=…) rather than caught by the loop. Qualify the slot-preservation statement
to note that ordinary failures become BatchItem entries while KeyboardInterrupt
and SystemExit propagate, consistent with batch.md.
- Around line 31-32: Update the code around item.value.to_dict(mode="compact")
to retain the compact envelope rather than assigning it to the discard variable.
Store the resulting payload in the collection, sink, or variable consumed by the
next iteration or referee, preserving the existing compact serialization mode.

In `@docs/sphinx/api/errors.rst`:
- Around line 172-178: Update the BudgetExceededError documentation to include
the run_with_wall_fallback timeout path, stating that it raises E-BUDGET-001
when the Python wall-clock fallback reaches its timeout without requiring a
cooperative engine checkpoint.

In `@docs/sphinx/api/workload.rst`:
- Around line 50-55: Update the documented run_with_wall_fallback signature to
require the keyword-only budget argument, matching the runtime definition in
run_with_wall_fallback and removing the misleading None default.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 27f20d18-4544-488c-88cd-59a2542cee6d

📥 Commits

Reviewing files that changed from the base of the PR and between 0935c87 and bddf84b.

📒 Files selected for processing (15)
  • CHANGELOG.md
  • README.md
  • docs/mdbook/src/SUMMARY.md
  • docs/mdbook/src/batch.md
  • docs/mdbook/src/budgets.md
  • docs/mdbook/src/claim-graphs.md
  • docs/mdbook/src/derivations.md
  • docs/mdbook/src/getting-started.md
  • docs/mdbook/src/intro.md
  • docs/mdbook/src/python-api.md
  • docs/mdbook/src/search-plumbing.md
  • docs/sphinx/api/core.rst
  • docs/sphinx/api/errors.rst
  • docs/sphinx/api/workload.rst
  • docs/sphinx/index.rst

Comment thread docs/mdbook/src/intro.md
Comment on lines +17 to +23
**Agent loops.** Budgets and cancellation, batch APIs that never abort on one bad candidate, versioned compact result envelopes, and session-level [claim graphs](./claim-graphs.md) are first-class — see [Autoresearch / agent loops](./search-plumbing.md).

## Design principles

**Explicit representations.** The type system distinguishes `UniPoly` (FLINT-backed univariate polynomial), `MultiPoly` (sparse multivariate), `RationalFunction`, and the generic `Expr` tree. Converting between them is an explicit call. There are no silent representation changes hiding performance cliffs.

**Stateless by design.** No global assumption contexts. No hidden caches that change behavior. All context (domains, simplification policy, precision) is passed explicitly or bundled into expression structure. This makes results deterministic and parallelism safe.
**Stateless by design.** No global assumption contexts. No hidden caches that change behavior. All context (domains, simplification policy, precision, budgets) is passed explicitly or scoped through `context(...)`. This makes results deterministic and parallelism safe.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Qualify the determinism claim for wall-clock budgets.

wall_ms depends on machine load and parallel scheduling. A seed does not make wall-clock cutoffs deterministic. State that explicit context improves reproducibility, while step and seed controls can be deterministic and wall-clock limits are best effort.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/mdbook/src/intro.md` around lines 17 - 23, Update the “Stateless by
design” determinism claim to distinguish reproducibility from strict
determinism: explain that explicit context improves reproducibility, step and
seed controls can be deterministic, and wall-clock budgets such as wall_ms
remain best-effort because they depend on machine load and scheduling.

Comment on lines +31 to +32
# Token-cheap record for the next iteration / a human referee
_ = item.value.to_dict(mode="compact")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep the compact envelope instead of discarding it.

_ = item.value.to_dict(mode="compact") creates the payload and immediately drops it. This does not create a record for the next iteration or a referee. Store the payload in a list, log sink, or variable used by the next step.

Proposed fix
+records = []
 with ak.research.session(title="Sweep", pool=pool, capture=True) as s:
     with ak.context(pool=pool, budget=ak.Budget(wall_ms=200, max_steps=50_000, seed=7)):
         for item in ak.integrate_many(candidates, x, parallel=True):
             if not item.ok:
                 continue
-            _ = item.value.to_dict(mode="compact")
+            records.append(item.value.to_dict(mode="compact"))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/mdbook/src/search-plumbing.md` around lines 31 - 32, Update the code
around item.value.to_dict(mode="compact") to retain the compact envelope rather
than assigning it to the discard variable. Store the resulting payload in the
collection, sink, or variable consumed by the next iteration or referee,
preserving the existing compact serialization mode.

Comment on lines +39 to +43
- A **budget trip is a fine answer**, not a crash — catch `BudgetExceededError`
(`E-BUDGET-*`) and deprioritize that candidate.
- A **batch never drops a slot** — failures become `BatchItem(ok=False, error=…)`.
- **Compact mode never hides verification status** — `verification["status"]`
stays readable; Lean source is omitted on purpose.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Align the failure-handling rules with batch_map.

integrate_many uses the batch path, so candidate BudgetExceededError failures become BatchItem(ok=False, error=...); the loop does not catch the exception directly. Also, a batch does not “never” drop a slot because KeyboardInterrupt and SystemExit propagate, as documented in docs/mdbook/src/batch.md lines 118-121. Distinguish direct-call handling from batch-result handling and qualify the slot-preservation claim.

Proposed wording
- A budget trip is a fine answer, not a crash — catch `BudgetExceededError`
- (`E-BUDGET-*`) and deprioritize that candidate.
- A batch never drops a slot — failures become `BatchItem(ok=False, error=…)`.
+ For direct calls, catch `BudgetExceededError` (`E-BUDGET-*`). For batch
+ calls, inspect `BatchItem.error` and deprioritize failed candidates.
+ Batch calls preserve a slot for ordinary `Exception` failures, but
+ `KeyboardInterrupt` and `SystemExit` still stop the batch.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- A **budget trip is a fine answer**, not a crash — catch `BudgetExceededError`
(`E-BUDGET-*`) and deprioritize that candidate.
- A **batch never drops a slot** — failures become `BatchItem(ok=False, error=…)`.
- **Compact mode never hides verification status**`verification["status"]`
stays readable; Lean source is omitted on purpose.
For direct calls, catch `BudgetExceededError` (`E-BUDGET-*`). For batch
calls, inspect `BatchItem.error` and deprioritize failed candidates.
Batch calls preserve a slot for ordinary `Exception` failures, but
`KeyboardInterrupt` and `SystemExit` still stop the batch.
- **Compact mode never hides verification status**`verification["status"]`
stays readable; Lean source is omitted on purpose.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/mdbook/src/search-plumbing.md` around lines 39 - 43, Update the
failure-handling bullets in search-plumbing.md to distinguish direct-call
handling from integrate_many’s batch-result handling: BudgetExceededError from
batch candidates is represented as BatchItem(ok=False, error=…) rather than
caught by the loop. Qualify the slot-preservation statement to note that
ordinary failures become BatchItem entries while KeyboardInterrupt and
SystemExit propagate, consistent with batch.md.

Comment on lines +172 to +178
.. exception:: BudgetExceededError

Code prefix ``E-BUDGET-*``. A cooperative budget or cancellation trip —
not a mathematical failure. Raised when an active
:class:`~alkahest.Budget` is exceeded (or :func:`~alkahest.request_cancel`
was called) at a checkpoint inside an engine that honors budgets
(notably :func:`~alkahest.integrate`). See the

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Document the Python wall-clock fallback path.

python/alkahest/_budget.py:145-201 also raises BudgetExceededError with E-BUDGET-001 when run_with_wall_fallback reaches its timeout. This path does not require a cooperative engine checkpoint. Add it to this exception description so callers know the complete error boundary.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/sphinx/api/errors.rst` around lines 172 - 178, Update the
BudgetExceededError documentation to include the run_with_wall_fallback timeout
path, stating that it raises E-BUDGET-001 when the Python wall-clock fallback
reaches its timeout without requiring a cooperative engine checkpoint.

Comment on lines +50 to +55
.. function:: run_with_wall_fallback(fn, *args, budget=None, **kwargs)

Python-layer wall-clock fallback for callables that cannot raise
:exc:`BudgetExceededError` through their own return type (e.g.
:func:`simplify`). Prefer ``context(budget=...)`` for engines that already
honor Rust cooperative checkpoints.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Make budget required in the documented signature.

The runtime signature in python/alkahest/_budget.py:145-201 requires the keyword-only argument budget: Budget. Documenting budget=None advertises a call that raises TypeError before the function runs.

-.. function:: run_with_wall_fallback(fn, *args, budget=None, **kwargs)
+.. function:: run_with_wall_fallback(fn, *args, budget, **kwargs)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.. function:: run_with_wall_fallback(fn, *args, budget=None, **kwargs)
Python-layer wall-clock fallback for callables that cannot raise
:exc:`BudgetExceededError` through their own return type (e.g.
:func:`simplify`). Prefer ``context(budget=...)`` for engines that already
honor Rust cooperative checkpoints.
.. function:: run_with_wall_fallback(fn, *args, budget, **kwargs)
Python-layer wall-clock fallback for callables that cannot raise
:exc:`BudgetExceededError` through their own return type (e.g.
:func:`simplify`). Prefer ``context(budget=...)`` for engines that already
honor Rust cooperative checkpoints.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/sphinx/api/workload.rst` around lines 50 - 55, Update the documented
run_with_wall_fallback signature to require the keyword-only budget argument,
matching the runtime definition in run_with_wall_fallback and removing the
misleading None default.

@codspeed-hq

codspeed-hq Bot commented Aug 8, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 35 untouched benchmarks
⏩ 49 skipped benchmarks1


Comparing docs/search-plumbing-docs (bddf84b) with main (0935c87)

Open in CodSpeed

Footnotes

  1. 49 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@AregGevorgyan
AregGevorgyan merged commit 9cbf3bd into main Aug 8, 2026
13 checks passed
@AregGevorgyan
AregGevorgyan deleted the docs/search-plumbing-docs branch August 8, 2026 20:34
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.

1 participant