Skip to content

feat(search): find skills for a sentence with task search - #452

Merged
harlan-zw merged 1 commit into
mainfrom
feat/search-stage2
Oct 6, 2026
Merged

harlan-zw merged 1 commit into
mainfrom
feat/search-stage2

Conversation

@harlan-zw

Copy link
Copy Markdown
Collaborator

🔗 Linked issue

Related to #440

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

Stage 1 search rewrites a sentence once and cannot judge its results. "stop memory leaks in node" still returns Godot, Tokio and iOS Skills. #440 planned a stage 2 agent loop on Claude Haiku 4.5. An offline eval found GPT-6 Luna better than stage 1 on 15 of 20 sentences, at 20 to 40 times less than the Haiku estimate.

This adds task search. For a sentence, the search panel shows a "Find skills for this task" row at its foot. Nothing runs until a visitor selects it. Then POST /api/skills/task-search runs a short loop:

  • GPT-6 Luna writes up to 4 searches a turn, over at most 3 turns, with reasoning off.
  • Each search is the registry's own querySkills, 15 results each, with a ready ref per result.
  • The model answers refs only. snapRefs keeps refs the searches returned and drops the rest, so the model can filter and order the registry but never add to it.
  • Found Skills replace the stage 1 rows under "Skills for this task". Every other outcome keeps the stage 1 rows and shows a calm status line.

Architecture: the panel row posts to the new task search route, which checks the KV cache, the kill switch, the daily budget and the visitor limit before the pure loop calls GPT-6 Luna through the Workers AI binding and the registry's own search

Model path. The existing Workers AI binding takes openai/gpt-6-luna with a Chat Completions body and bills AI Gateway credits. It needs no new secret and no dashboard step. Chat Completions refuses function tools with reasoning on this model, so reasoning_effort is none.

Cost and abuse.

  • Answers are cached in KV by a hash of the normalised sentence: 7 days for found, 1 day for none. A cached answer is served even over a limit.
  • TASK_SEARCH_RATE_LIMIT allows 3 model runs a minute per IP. A rate limit binding takes 60 seconds at most, and a daily count per visitor would mean storing an IP hash. The daily ceiling is therefore global: runtimeConfig.taskSearch.dailyBudgetMicros, $1 a UTC day, counted from token usage in KV. KV has no atomic increment, so the ceiling is soft.
  • Set the Worker variable NUXT_TASK_SEARCH_ENABLED=false to switch it off without a deploy.
  • Each request emits one task-search wide event with outcome, turns, searches, tokens, cost and duration. It never carries the question.

Scope calls.

  • The loop has only search_skills. get_skill and get_collection were never called in 41 eval conversations, and collections belong to another layer under ADR-0001.
  • The copy names the model's part as "a language model", as VISION.md labels machine-generated search metadata. Nothing calls skilld AI-powered.
  • GLOSSARY.md gains task search. It displaces "search stage 2", "AI search", "smart search" and "deep search". COPY.md lists the row strings.
  • The privacy page now says that a task search sends the sentence and the search results to OpenAI through Cloudflare, and nothing that identifies the visitor.

Measured. The shipped core ran 20 sentences against the real model and production search, from a desktop rather than a Worker:

Result
Found Skills 18 of 20; the 2 sentences with no fitting Skill answered none
Refs dropped by snapRefs 0
Cost per question $0.0005 mean, $0.0006 max
Duration 5.1s median, 7.3s p90

🤖 AI disclosure: Harlan Agent Kit modified this description. My AI open-source policy.

A sentence in the search box can now ask a language model to run a few
registry searches and keep the Skills that fit. Stage 1 misses tasks
whose words point at the wrong runtime, such as Godot and Tokio Skills
for a Node memory leak. The model runs only on an explicit click, is
capped per visitor and per day, and can only pick Skills its searches
returned.
@harlan-zw harlan-zw added the harlan-agent-review Pull request triage requires an adversarial Review. Adding this label manually always forces one. label Oct 6, 2026
@harlan-zw

Copy link
Copy Markdown
Collaborator Author

🤖 Agent comment: checked by hand, since CI cannot cover it.

  • A scratch Worker called platform.ai.run('openai/gpt-6-luna', …) with tools, tool results and a JSON schema response format. All three returned 200 through the binding.
  • The shipped runTaskSearch ran 20 sentences against the real model and production /api/v1/skills: 18 found, 2 none, 0 dropped refs, $0.0005 mean per question.
  • On nuxi dev with a copy of local D1: a cased variant of a sentence hit the KV answer cache in 36ms, a single word got 400, and the 4th model run inside a minute got limited for the visitor. The task-search wide event carried tokens and cost and no question text.
  • Selecting the row kept focus in the box, so the panel stayed open while the model ran. A first version closed it; the mousedown guard in SkillSearchPanel.vue fixes that.
  • Total model spend for this work: about $0.012.
Offer, desktop dark Running, desktop light
Offer row at the foot of the panel, desktop dark Running status, desktop light
Found, desktop dark Nothing fits, 390px light
Found Skills under their heading, desktop dark No skill fits status with stage 1 rows kept, 390px light
Found, 390px dark
Found Skills, 390px dark

The Nuxt devtools badge in the lower corner appears in dev only. The local registry is sparse, so local answers are thinner than production's.

@harlan-github-agent harlan-github-agent Bot added harlan-agent-review-required Pull request triage requires an adversarial Review for this head commit. harlan-agent-running An Agent holds a Task on this issue or pull request right now. and removed harlan-agent-review Pull request triage requires an adversarial Review. Adding this label manually always forces one. labels Oct 6, 2026
@harlan-github-agent

harlan-github-agent Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🤖 MERGED

Harlan Agent Kit posted this automated review. It is not Harlan's personal review or approval. AI open source policy. Last updated: 2026-10-06 03:35 UTC.

GitHub merged this pull request.

  • Logged (30/100): Every screenshot backing the UI claims is inaccessible to this review, so clipping, contrast, and responsive behavior are unverified. View code
    • Ask an agent to verify and fix this finding
  • Logged (25/100): A cached task-search answer can link to a 410 tombstone for up to 7 days after the Skill's source disappears. View code
    • Ask an agent to verify and fix this finding
  • Logged (20/100): A registry search failure mid-loop turns into an unrecorded 500 that skips spend accounting and the wide event. View code
    • Ask an agent to verify and fix this finding
  • Logged (25/100): One zero-cost scripted visitor can darken task search site-wide until the UTC day rolls over. View code
    • Ask an agent to verify and fix this finding

86bc6728-b046-4263-9ad6-57d0abf2b382

Selected findings run after merge and open separate pull requests.

@harlan-github-agent harlan-github-agent Bot added harlan-agent-running An Agent holds a Task on this issue or pull request right now. harlan-agent-review-required Pull request triage requires an adversarial Review for this head commit. harlan-agent-ready The automated Review passed every gate on this head commit. and removed harlan-agent-running An Agent holds a Task on this issue or pull request right now. harlan-agent-review-required Pull request triage requires an adversarial Review for this head commit. labels Oct 6, 2026

@harlan-github-agent harlan-github-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Harlan Agent Kit posted this automated review. AI open source policy.

Automated Review: READY.

Read the Review results

@harlan-zw
harlan-zw merged commit 835dc88 into main Oct 6, 2026
7 checks passed
@harlan-github-agent harlan-github-agent Bot removed the harlan-agent-ready The automated Review passed every gate on this head commit. label Oct 6, 2026
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