Skip to content

feat(agentic): ranked reasoner search + ambient load metadata (beta-plan: Santosh's recommendations) - #784

Merged
AbirAbbas merged 2 commits into
mainfrom
feat/agentic-reasoner-search-load-meta
Jul 16, 2026
Merged

feat(agentic): ranked reasoner search + ambient load metadata (beta-plan: Santosh's recommendations)#784
AbirAbbas merged 2 commits into
mainfrom
feat/agentic-reasoner-search-load-meta

Conversation

@AbirAbbas

Copy link
Copy Markdown
Contributor

Implements the two remaining beta-plan recommendations ("Santosh's recommendations") for the sub-harness flow, where a coding agent (Claude Code, Codex, …) drives AgentField through the af agent JSON CLI and the agentfield-use skill.

1. Reasoner discovery at scale — ranked search

With hundreds of reasoners installed, the driving agent must search, not list-and-scan.

  • GET /api/v1/agentic/reasoners?q=<free text>&agent=<optional id>&limit=<1..50> — ranks all registered reasoners with a dependency-free BM25F-lite index built per request from the same registration data the discovery surface serves (results never drift from discovery). Field boosts: reasoner id 3.0 > tags 2.0 > agent id 1.5 > metadata description 1.0; the tokenizer splits snake/kebab/camelCase (query "pr resolve" matches run_pr_resolver); ties break deterministically by invocation target.
  • Each hit carries reasoner_id, agent_id, invocation_target, tags, score, agent_health — the brain can dispatch immediately with no second lookup.
  • CLI: af agent search "<free text>" [--agent <id>] [--limit N].
  • Empty q → structured missing_query error.

2. Ambient machine-load metadata — zero extra round-trips

The brain must know how loaded the machine is before starting more heavy agents, without asking.

  • Every agentic response now carries meta.load = {running_agents, total_agents, active_executions, cpu_cores, recommended_max_concurrent}, stamped centrally in respondOK via a load provider registered at route setup.
  • Provider caches for 2s so bursts don't hammer storage; on any error meta.load is silently omitted — it can never fail a response. recommended_max_concurrent = max(1, cores/2) (cores-based; memory-aware refinement noted in-code as follow-up).
  • The af agent CLI already forwards server meta into its JSON output, so driving agents get this on every call for free.

Skill wiring

agentfield-use v0.2.0 → v0.3.0 (embedded mirror synced, sync-embedded-skills.sh --check passes):

  • "Too many reasoners to scan? Search, don't dump" — use af agent search past ~20 reasoners; dispatch from invocation_target; prefer agent_health == "active".
  • "Check the load before piling on" — read meta.load; if active_executions >= recommended_max_concurrent, finish in-flight work before launching more, and tell the user when throttling.

Testing

  • 20 new unit tests (BM25 ranking/tokenizer, reasoners endpoint incl. filters/clamps/error paths, load-provider caching/fallback, envelope marshaling, CLI subcommand mapping) — internal/handlers/agentic and targeted internal/cli / internal/skillkit suites green.
  • Runtime-verified end-to-end on a live control plane with 78 registered reasoners across 4 agents: af agent search "review pull request" ranks pr-af-go:review_dimension / pr-af-go:review on top; --agent swe-planner + "plan a development sprint" returns swe-planner:plan then run_sprint_planner; meta.load present on every response (16-core machine → recommendation 8); empty query returns the structured error.

Notes

  • No new module dependencies; corpus rebuilt per request (small population) — no background indexing.
  • Known pre-existing Windows-only test quirks in untouched files (internal/cli captureOutput pipe-buffer deadlock, skillkit /tmp/HOME assumptions) are unaffected; Linux CI is the arbiter.

🤖 Generated with Claude Code

@AbirAbbas
AbirAbbas requested a review from a team as a code owner July 16, 2026 13:48
@github-actions

Copy link
Copy Markdown
Contributor

📊 Coverage gate

Thresholds from .coverage-gate.toml: per-surface ≥ 84%, aggregate ≥ 85%, max per-surface regression ≤ 1.0 pp, max aggregate regression ≤ 0.50 pp.

Surface Current Baseline Δ
control-plane 86.80% 87.40% ↓ -0.60 pp 🟡
sdk-go 92.50% 92.00% ↑ +0.50 pp 🟢
sdk-python 93.82% 93.73% ↑ +0.09 pp 🟢
sdk-typescript 90.44% 90.42% ↑ +0.02 pp 🟢
web-ui 84.76% 84.79% ↓ -0.03 pp 🟡
aggregate 85.51% 85.75% ↓ -0.24 pp 🟡

✅ Gate passed

No surface regressed past the allowed threshold and the aggregate stayed above the floor.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

📐 Patch coverage gate

Threshold: 80% on lines this PR touches vs origin/main (from .coverage-gate.toml:thresholds.min_patch).

Surface Touched lines Patch coverage Status
control-plane 337 83.00%
sdk-go 0 ➖ no changes
sdk-python 0 ➖ no changes
sdk-typescript 0 ➖ no changes
web-ui 0 ➖ no changes

✅ Patch gate passed

Every surface whose lines were touched by this PR has patch coverage at or above the threshold.

Comment thread control-plane/internal/handlers/agentic/reasoners.go Fixed
AbirAbbas and others added 2 commits July 16, 2026 10:03
Two beta-plan items ("Santosh's recommendations") for the sub-harness
flow, where a coding agent drives AgentField through `af agent` and the
agentfield-use skill:

1. Reasoner discovery at scale. With hundreds of reasoners installed
   the brain must search, not list. New GET /api/v1/agentic/reasoners
   ?q=<free text>&agent=<id>&limit=<1..50> ranks reasoners with a
   dependency-free BM25F-lite index built per request from the same
   registration data discovery serves (id boost 3.0, tags 2.0, agent
   1.5, metadata description 1.0; snake/kebab/camelCase-aware
   tokenizer; deterministic tie-break). Each hit carries
   invocation_target + agent_health so the brain dispatches with no
   second lookup. CLI: `af agent search "<text>" [--agent] [--limit]`.

2. Ambient machine-load metadata. Every agentic response now carries
   meta.load = {running_agents, total_agents, active_executions,
   cpu_cores, recommended_max_concurrent} via a load provider stamped
   into respondOK (2s TTL cache; omitted silently on error — never
   fails a response). recommended_max_concurrent = max(1, cores/2),
   cores-based; memory-aware refinement noted as follow-up. The
   `af agent` CLI already forwards server meta, so the driving agent
   gets load data with zero extra round-trips.

The agentfield-use skill (v0.2.0 -> v0.3.0, embedded mirror synced)
teaches both: search-first discovery past ~20 reasoners, and pacing —
if active_executions >= recommended_max_concurrent, finish in-flight
work before launching more.

Verified end-to-end on a live control plane with 78 registered
reasoners: "review pull request" ranks pr-af-go:review_dimension /
review on top, --agent filters, empty q -> structured missing_query,
meta.load rides every response (16 cores -> recommendation 8).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CodeQL (go/uncontrolled-allocation-size) does not track the limit clamp
through getIntQuery. Allocate at the constant max (50) instead - the
loop still stops at the requested limit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@AbirAbbas
AbirAbbas force-pushed the feat/agentic-reasoner-search-load-meta branch from 9d802cb to 3f954bc Compare July 16, 2026 14:03
@AbirAbbas
AbirAbbas merged commit 4db5244 into main Jul 16, 2026
25 checks passed
@AbirAbbas
AbirAbbas deleted the feat/agentic-reasoner-search-load-meta branch July 16, 2026 14:58
AbirAbbas added a commit that referenced this pull request Jul 16, 2026
…licts)

Conflict resolutions:
- agent_commands.go: union requires_auth — keep #784's reasoners endpoint
  alongside the executions steering endpoints
- commands/install.go: keep both --json (this PR) and --path (#750);
  thread path through executeJSON so the flags compose
- logs.go: keep runtime import from main
- stop.go: keep JSON-aware printf/Outcome from this PR plus main's
  ErrProcessDone guard and markStopped refactor; route main's new
  stale-registry warnings through the quiet-aware printer so --json
  stdout stays machine-readable

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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