Skip to content

Update rag.md -- remove fancy quotes#3

Merged
kevinthecheung merged 1 commit into
mainfrom
kevinthecheung-patch-1
May 1, 2024
Merged

Update rag.md -- remove fancy quotes#3
kevinthecheung merged 1 commit into
mainfrom
kevinthecheung-patch-1

Conversation

@kevinthecheung
Copy link
Copy Markdown
Contributor

No description provided.

@kevinthecheung kevinthecheung merged commit 8a94198 into main May 1, 2024
@kevinthecheung kevinthecheung deleted the kevinthecheung-patch-1 branch May 1, 2024 21:10
pavelgj pushed a commit that referenced this pull request May 1, 2024
Co-authored-by: Chris Chestnut <cchestnut@google.com>
Co-authored-by: Cleo Schneider <cleoschneider@google.com>
Co-authored-by: Samuel Bushi <ssbushi@google.com>
pavelgj pushed a commit that referenced this pull request May 1, 2024
inlined added a commit to inlined/genkit that referenced this pull request Nov 15, 2024
Example is for structured output but the schema was string.
cabljac referenced this pull request in invertase/genkit Nov 25, 2025
Co-authored-by: Chris Chestnut <cchestnut@google.com>
Co-authored-by: Cleo Schneider <cleoschneider@google.com>
Co-authored-by: Samuel Bushi <ssbushi@google.com>
chrisraygill added a commit that referenced this pull request May 29, 2026
…upes, dead schema

Four implementation simplifications that don't change observable
behavior (except #3, which tightens the tool-error contract).

1) Consolidate snapshot rehydrate + background poll into a single
   `applySnapshot(snapshotId)` helper on `AgentSession`. Both methods
   previously did the same runFlow → state.{messages,artifacts,custom}
   → check status logic with subtle drift (the poll handled 'aborted',
   rehydrate didn't). The helper returns the snapshot's terminal
   status; callers decide their own phase semantics. `continueFrom`
   also routes through it. ~30 LOC of duplication gone.

2) Drop the StrictMode dispose dance from the React adapter. The
   trickiest 15 LOC in the whole stack — Promise.resolve().then +
   hasActiveSubscribers() check + microtask deferral — goes away.
   Replaced with a `listeners.size === 0` self-termination check
   inside `startBackgroundPoll`: when no one is subscribed, the poll
   stops on its next tick. `useSyncExternalStore` already manages
   subscribe/unsubscribe correctly, so the listener Set empties on
   unmount. AbortControllers are GC-safe. No explicit dispose needed
   from the adapter; the session lazy-init via useRef just works
   under StrictMode's double-mount. `hasActiveSubscribers()` removed
   from the public API.

3) Make `metadata.toolError` the only `tool-error` detection signal.
   Drop the two heuristic fallbacks (`{error}`/`{status:'error'}`
   shape, and the `Tool '<name>' failed:` string match) from
   `detectToolError`. Patch the stock filesystem middleware to set
   `metadata.toolError = { message }` on the response envelope so
   the runtime can find it. Detection lives at one explicit opt-in
   flag; the implementation now matches the protocol's promise of
   "no more string matching". Third-party middleware that catches
   tool throws and returns error-shaped responses without setting
   the flag won't surface as `tool-error` events — the conversation
   still proceeds (model sees the error in output) but the typed
   client signal is gone. Documented tradeoff.

   Bug caught while wiring this up: the metadata flag lives on the
   *part* envelope, not on the `toolResponse` value. The runtime
   now passes both to the detector.

4) Drop the unused `artifact-start`/`artifact-delta`/`artifact-complete`
   schema variants from `AgentStreamChunkSchema` (and the matching
   client visitor case). The schema comment had been calling them
   "reserved; runtime emits artifact-emitted for now" since they
   were introduced — three reserved-but-never-emitted variants is
   protocol noise. Add them back at the moment the emission site
   exists.

End-to-end verified:
- React: WeatherChat tool-call lifecycle + BankingInterrupt in-stream
  interrupt + URL push. Zero errors.
- Angular: WeatherChat + BankingInterrupt + BackgroundAgent (phase
  transitioned background → done at t=18s, 9.5KB report). Zero errors.
- tool-error event still fires via metadata signal: 2 events emitted
  in a curl test driving read_file ENOENT (one for list_files probe,
  one for read_file), each with addressable toolCallId and clean
  errorText.

Net LOC across all four: ~80 saved, plus the React adapter's
trickiest code path retired. Protocol vocabulary contracts from 12
variants to 10.
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