Skip to content

feat(web-search): worker-side search — capability, Tavily, streaming, v2 capture, greedy inference#2

Open
lightchainaidev wants to merge 17 commits into
mainfrom
feat/web-search
Open

feat(web-search): worker-side search — capability, Tavily, streaming, v2 capture, greedy inference#2
lightchainaidev wants to merge 17 commits into
mainfrom
feat/web-search

Conversation

@lightchainaidev

Copy link
Copy Markdown
Contributor

Part of the Web Search feature (v1 + v1.1 streaming + v2).

  • Advertises search capability; SEARCH_*/TAVILY_* config; Tavily client; stage 4.5 one-shot augmentation.
  • Token streaming over the relay; sources emitted after the answer; relay complete carries the plain answer.
  • v2: captures {answer,searchContext} envelope into the response blob; history decodes envelopes.
  • Deterministic inference (temperature 0 + seed) so dispute re-execution reproduces (verified: similarity 1.0).

Depends on the lightchain-shared-pkg web-search PR (merge that first).

🤖 Generated with Claude Code

lightchainaidev and others added 17 commits June 23, 2026 18:29
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move PublishMetadata call from stage 4.5 (pre-inference) to after stage 6
(response encrypted) so citations are delivered to the relay/UI after the
answer, not before it. Search and prompt augmentation are unchanged — only
the publish is deferred.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Switch TestStage5_StreamsChunks deltas from ["Hello, streaming world!", " Done."]
to ["Hello, streaming world!!", "Done"]: the first delta (24 bytes) hits the >=24
threshold and triggers a mid-stream flush (seq=1); the second delta (4 bytes) stays
below threshold and is flushed by the post-loop flushChunk() call (seq=2). Tighten
the assertion from require.NotEmpty to assert.Equal(t, []uint32{1,2}, seqs) so both
the threshold-flush and final-remainder-flush paths are explicitly exercised.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ture)

- Import pkg/searchaug; add toSearchaugSources() converter (search.Source → searchaug.Source)
- Stage 4.5: replace local buildSearchAugmentedPrompt with searchaug.BuildAugmentedPrompt;
  carry searchSources as []searchaug.Source to stage 6
- Stage 6: wrap response in searchaug.EncodeResponse before encrypting; non-search jobs
  get raw answer bytes (byte-identical to legacy format)
- sourcesMetadataJSON now accepts []searchaug.Source; relay-frame {type,sources} shape unchanged
- Remove local buildSearchAugmentedPrompt (template moved to pkg in Task 1)
- Remove TestBuildSearchAugmentedPrompt_FixedFormat (coverage moved to pkg)
- Add TestStage6_EmitsEnvelopeForSearchJob and TestStage6_RawAnswerForNonSearchJob

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…answer (v2 parity)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…2 envelope

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…) for reproducible re-execution

Add Options{Temperature:0, Seed:42} to all four Ollama request paths
(Generate, Chat, GenerateStream, ChatStream). Temperature is not
omitempty so the zero value is always serialised; omitting it lets
Ollama default to 0.8 (random sampling), causing worker/disputer
outputs to diverge and trigger false disputes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace p.SearchEnabled (dispatcher-supplied flag) with
searchaug.DecodePrompt so the search decision is authoritative in the
encrypted blob. A decode error is now a hard stage-4 failure. Remove the
dead SearchEnabled field from JobPayload. Update existing search tests to
supply blobs built via searchaug.EncodePrompt(text, true) instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <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.

1 participant