Skip to content

Pair agentic contexts with profile attributes in the Google ADK tutorial - #1897

Draft
jborlase-snowplow wants to merge 5 commits into
mainfrom
update/adk-agentic-context
Draft

Pair agentic contexts with profile attributes in the Google ADK tutorial#1897
jborlase-snowplow wants to merge 5 commits into
mainfrom
update/adk-agentic-context

Conversation

@jborlase-snowplow

Copy link
Copy Markdown
Contributor

What changed?

Retrofits tutorials/signals-google-adk-agent/ to use agentic contexts natively: an agentic-context definition step (Console + Python SDK tabs, mirroring the Vercel retrofit's structure), and the before_model_callback now composes BOTH the profile attributes and the narrative into the instructions via append_instructions, with when-to-use-which guidance (per product direction). Also fixes the same truthy-None guard bug in its Python (if not attributes: never fires on a dict of Nones), fixes four pre-existing convention violations (missing free-trial note among them), and replaces the stale architecture PNG (which contradicted the page's own model name) with a Mermaid diagram.

Why?

Same rationale as the Vercel retrofit — the tutorial hand-rolled what agentic contexts now provide.

Reviewer guidance

  • Verified against live Signals up to the model call: six real events → exact-value assertions (page_views_count == 6, unique_pages_viewed with one revisit correctly deduplicated), instruction composition proven. The Gemini call is unverified — no GOOGLE_API_KEY available, none substituted.
  • Console tab is aligned to the live-verified create form (from the agentic-contexts tutorial's Console walk) — but this tutorial's own screenshots are pending a browser pass that lands on this PR shortly, along with settling whether unique_pages_viewed holds full URLs or paths (the one place two examples disagree; flagged rather than invented).
  • Reviewer decision requested: this tutorial's pre-existing service is web_agent_context (underscores) while the Vercel tutorial's is web-agent-context (hyphens) — pick a convention; neither PR silently renames.
  • Merge note: Add free trial note to Signals tutorial intros #1884 touches this tutorial's introduction too (trivial conflict); merge Add free trial note to Signals tutorial intros #1884 first.

🤖 Generated with Claude Code

jborlase-snowplow and others added 2 commits July 29, 2026 17:55
The signals-google-adk-agent tutorial pre-dates agentic contexts and
hand-rolled what the feature now provides: build-agent.md composed a
"Real-Time User Context" markdown block from attribute values via a
custom _format_attributes() helper.

Retrofit it as a pairing rather than a replacement, matching the U1
Vercel retrofit. The before_model_callback now fetches both kinds of
Signals context and appends both to the system instruction, and the
tutorial explains when each is the right tool:

- user-level profile attributes (computed aggregates, via the service)
- in-session agentic context (recent activity as an LLM-ready narrative,
  via get_agentic_context with format="narrative")

Changes:
- configure-signals.md: add an agentic-context definition step with
  Console and Python SDK tabs, selecting event_name and page_urlpath so
  the narrative's table columns populate
- build-agent.md: replace the hand-built session-activity block with
  get_agentic_context(); the two fetches degrade independently, and
  append_instructions() takes both sections as a list. Both the
  narrative and the composed system instruction are real captures.
  Add the Snowplow Inspector verification step
- introduction.md: describe both context types and both fetches in the
  component flow; add the missing free-trial note; point the
  prerequisite at /docs/signals/setup/ instead of the credentials page
- project-setup.md: add SNOWPLOW_SIGNALS_AGENTIC_CONTEXT_NAME; correct
  the Signals base URL placeholder to https://YOUR_ID.signals...
- conclusion.md: list the agentic context in the summary

Two fixes beyond the retrofit itself:

- Drop None-valued attributes before formatting the profile section.
  get_service_attributes() returns a key for every attribute in the
  service, valued None until the session produces one, so the old
  "if not attributes" guard never fired and the agent would have sent
  "page_views_count: None" to the model.
- Unpin the preview model ID (gemini-3-flash-preview -> gemini-2.5-flash)
  and add a note on changing the model string.

Verified against a live trial org: the Python SDK block publishes as
written, six real Collector events produce the documented attribute
values and narrative, and the ADK before_model_callback composes an
instruction containing both sections. The Gemini call itself is
unverified — no Google AI/Vertex key was available.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…e PNG

Two gaps left open by d21b7ee, both closable without a browser.

The Console tab for the new agentic-context step was written from
docs/signals/agentic-contexts/index.md, which describes the create form
in prose rather than quoting its labels. Turning that prose into bold
control names produced fields the product doesn't have. Align it with
the form as observed in the live Console by the T4 tutorial's run:

- one scrolling Create context form with Details, Prompt, Lookback
  Window, and Events and Properties sections, not a five-step wizard
- Prompt, not "Prompt instructions"; Primary owner, not "Owner", and
  it arrives pre-filled
- Max events and Max age with a unit dropdown, so 30 minutes rather
  than 1800 seconds, and Console restates the resulting window
- Add event and Add property in Events and Properties
- Publish and Edit live on the details page, and edits start as drafts
- the list page's create button stays unnamed, since its label is
  unverified

Replace adk-architecture.png with a Mermaid flowchart. The PNG drew only
the attributes fetch, so it stopped matching the callback once the
agentic context landed alongside it, and it labelled the agent gemini-3
while the page uses gemini-2.5-flash. It can't be regenerated here, and
the style guide prefers Mermaid for architecture visuals. The diagram
carries what the PNG had plus the agentic context: both Signals
resources fed from enriched events, both fetches as labelled edges off
before_model_callback, and the two sections joining at
append_instructions. Deleting the PNG retires its now-incomplete alt
text, and the flow bullets above the diagram serve as its text
equivalent.

Verified with mermaid 11.14.0, the version the site ships: parse and
render both succeed, and the built HTML emits the same wrapper an
existing repo diagram does. yarn build passes. No code the reader runs
changed, and no Signals resources were created.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 30, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
documentation c8e5599 Commit Preview URL

Branch Preview URL
Jul 31 2026, 03:50 PM

@claude

claude Bot commented Jul 30, 2026

Copy link
Copy Markdown

Style review

Overall this is a solid, well-organized addition — the agentic context material is clearly explained, the new Mermaid diagram is a good replacement for the PNG (and no stale references to adk-architecture.png remain), code fences now specify languages, and every internal link target resolves (/docs/signals/concepts/#services, #attribute-groups, /docs/signals/agentic-contexts/, /docs/signals/applications/agentic-contexts/, /docs/signals/setup/, /docs/signals/connection/, /docs/testing/snowplow-inspector/signals-integration/, /docs/testing/snowplow-micro/). Both external URLs touched by this PR return 200: https://pypi.org/project/snowplow-signals/ and https://snowplow.io/get-started/snowplow-free-trial.

A handful of style points below.

1. "frontend" should be hyphenated (build-agent.md frontmatter)

"...and forward the Snowplow session ID from the React frontend through CopilotKit."

Style guide, General technical terms: "Always hyphenate: back-end, front-end, server-side, client-side." The same file's H2 already reads "Forward the session ID from front-end to agent", so this is internally inconsistent too.

Fix: "...from the React front-end through CopilotKit." (project-setup.md's description has the same wording, though this PR didn't touch that line — worth fixing while you're here.)

2. Filler word "simply" (build-agent.md)

"If you see that, your configuration is fine and Signals simply hasn't received qualifying events for this session yet."

Style guide, Writing style: "Remove filler words: 'simply', 'on top of that', 'in order to'."

Fix: "...your configuration is fine and Signals hasn't received qualifying events for this session yet."

3. Informal register: "a play-by-play" (configure-signals.md)

"To also give your agent a play-by-play of what the user is doing right now, define an agentic context"

CLAUDE.md, Writing style: "Use professional, technical tone."

Fix: "To also give your agent a chronological record of what the user is doing, define an agentic context".

4. build-agent.md is now at seven H2 sections

CLAUDE.md, Headings and organization: "Limit pages to 3-5 H2 sections. Create a new page if content exceeds this." The page was already over at six; this PR adds "Inspect the Signals integration in the browser", a single paragraph.

Fix: fold that paragraph into the end of "Verify Signals context" (it's a verification step), or demote it to an H3 there. That brings the count down without losing the Inspector pointer.

5. The attributes-vs-agentic-context explanation is duplicated across two pages

introduction.md:

"Use attributes when you want defined metrics that your agent, or any other consumer, can rely on."

build-agent.md:

"Reach for attributes when you want defined metrics that your agent, or any other consumer, can rely on: a page view count you can threshold on, or a list you can check membership against. Reach for the agentic context when..."

Style guide, Writing style: "Never re-explain concepts." The near-verbatim repetition two pages later means both copies have to be maintained.

Fix: keep the full "when to use which" explanation in introduction.md, and in build-agent.md reduce it to the two-bullet list plus one sentence, without restating the rationale.

6. Mixed click-path and prose (build-agent.md)

"To rerun the attribute group test query in Console, click Edit on your attribute group page > Run Preview."

> reads as a navigation breadcrumb elsewhere in this tutorial ("Signals > Overview"), so combining it with "click" is ambiguous about where the reader is.

Fix: "...click Edit on your attribute group page, then Run Preview."

7. Table column heading "Why" (configure-signals.md)

The cells are purpose statements ("Populates the event column of the narrative table"), which don't read as answers to "Why".

Fix: rename the column to "Purpose".

8. "Profile attributes" isn't established terminology

grep -riI "profile attributes" docs/signals/ returns nothing — the Signals docs call these simply "attributes" ("Profiles Store" and "Profiles API" are the only "profile" terms). Introducing a new label in a tutorial risks drifting from the product docs.

Fix: use "attributes" or "computed attributes" for the contrast with the agentic context, for example "computed attributes, served by a service" — or, if the pairing really needs two names, get the term added to the Signals docs first.

9. Bullet marker inconsistency (introduction.md)

The new list at the top uses * while the two adjacent lists on the same page use -. Both markers are allowed by the style guide, but mixing them within one page is inconsistent.

Fix: use - for the new list to match the page.

10. date frontmatter

CLAUDE.md defines date as the creation date, but the PR moves it forward on five pre-existing pages (2026-04-172026-07-29/2026-07-30), and does so inconsistently: configure-signals.md and introduction.md get 2026-07-30, while build-agent.md, project-setup.md, and conclusion.md get 2026-07-29.

Fix: either restore the original creation dates, or use one consistent date across the tutorial's pages.

11. Undeclared variable in the SDK tab (configure-signals.md)

"Start by connecting to Signals to create a Signals object, then define the agentic context" ... then later sp_signals.publish([web_agent_activity]).

sp_signals appears without ever being named, so the reader has to infer that it's the object from the connection step.

Fix: name it in the prose — "...to create a Signals object called sp_signals" — or show the assignment in the snippet.

Walked every Console instruction in this tutorial against the live trial
org, built each resource through the UI in the order the pages describe,
and corrected what the walk contradicted.

Two claims were false and are gone:

- Run Preview does not exist. Searched the DOM for "preview" at three
  points in the attribute-group lifecycle (create form with the template
  applied, details page while v1 (Not published), details page once
  v1 (Published)) and got zero matches every time. Both places that
  named it are rewritten: configure-signals.md gets the verified
  type/aggregation/property table, build-agent.md gets the
  null-attribute explanation that actually helps at that point. Caveat:
  this trial org has no warehouse connection and the removed copy
  described a warehouse query, so the control may be gated rather than
  absent — but the instruction was unconditional and wrong for a reader
  on the trial pipeline the prerequisites describe.
- unique_pages_viewed holds full URLs, not paths. The Basic Web template
  defines it as unique_list over the atomic page_url property, read from
  the create form and again from the created group's details page. The
  page's own example was right; the capture added by the previous run was
  the artifact, because it came from an SDK-built group using
  page_urlpath.

Rather than edit numbers by hand, the group was rebuilt through Console
from the template, republished, and the six-event journey re-sent. The
service response, the narrative, the composed system instruction, and the
agent log lines in build-agent.md now all come from one real session, and
configure-signals.md shows the same capture in place of an illustrative
block with invented values. The hedging sentence is replaced by the real
contrast: the service reads page_url, the agentic context reads
page_urlpath.

Console labels corrected from first-hand observation:

- sidebar is Attribute groups, and the create-form field is Attribute key
- the Basic Web template is applied by clicking Use on its card
- publishing a group deploys it to the Profiles Store, v1 (Not published)
  becomes v1 (Published)
- the service form's Attribute groups picker lists published groups only,
  so publishing first is required, not tidy
- service names take letters, numbers, and underscores only
- the agentic-contexts list page button is Create context
- Details fields are Name, Primary owner, Description in that order, and
  Primary owner is pre-filled and read-only
- Add event uses the Data structures tab and auto-fills version 1-0-0;
  Add property uses the Atomic tab
- the form submits with Create, the details page then shows Status Draft,
  and Publish opens a confirm dialog
- the details page shows Max Age (seconds) 1800 for the form's 30 minutes

Adds one screenshot of the Create context form, showing the Details and
Prompt sections with this tutorial's own values. The Lookback Window and
Events and Properties screen is identical to the one the agentic-contexts
tutorial already ships, so it is covered in prose instead of duplicated.

The Snowplow Inspector step is rewritten so every claim matches the page
it links, and now names the connect-and-credentials prerequisite and the
Attributes tab. It remains unexercised: this Chrome profile has no
extensions installed and installing one was out of scope.

yarn build passes with the image. Everything created was torn down and
the registry is confirmed empty.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jborlase-snowplow

Copy link
Copy Markdown
Contributor Author

Pushed f9dbd2f0 — the Console verification pass:

  • Live screenshot of the Create context form (Details + this tutorial's prompt) on the reader-facing web_agent_activity name; the Lookback/Events screen was captured, confirmed content-identical to the Vercel tutorial's, and deliberately not duplicated
  • Run Preview claims deleted (verified absent across the create/draft/published lifecycle on a trial org), replaced by the live-verified attribute table and a null-attribute explanation
  • unique_pages_viewed resolved with full URLs — the group was rebuilt through the Console Basic Web template and the six-event journey re-captured, after proving the extracted tutorial code was byte-identical to the prior run (the earlier paths-based capture came from an SDK-built group on page_urlpath); both pages now show the same real session
  • Console labels corrected from first-hand observation; the naming-divergence question is closed (Signals names reject hyphens — this tutorial's web_agent_context was always the legal form)
  • Inspector step tightened against its docs page but remains unexercised (no extension available in the verification browser)

Remaining known gap (unchanged): the Gemini call needs a Google AI/Vertex credential; everything up to and including the composed instructions is verified.

🤖 Generated with Claude Code

Rephrase the sample service response and narrative capture so they no
longer refer to our own test runs, and point readers at the Console
edit-and-publish flow for changing a published agentic context.
@jborlase-snowplow

Copy link
Copy Markdown
Contributor Author

Pushed e52fe59c — editorial sweep per product direction: capture-framing prose neutralized, and a positive Console edit-and-publish sentence added to the Python tab so both agent retrofits teach the same flow.

🤖 Generated with Claude Code

Featured the AI-assisted route: a new "Ask the Snowplow Assistant" section
carries a copy/paste prompt that creates and publishes the attribute group,
service, and agentic context, ahead of the manual Console steps.

Trimmed to the owner's lens: dropped the Micro/"full pipeline" panel for a
minimal prerequisite and added the missing completion-time line, converted the
React-framework and model-choice panels to prose, removed the duplicated
attributes-vs-agentic-context explanation that introduction.md already carries,
and reframed the verification steps positively.

Dropped internal-verification artifacts from the agent log sample (HTTP status
lines and the character count), and matched the log statement in the code to
the output now shown.

Folded "Try it out", "Verify Signals context", and the Inspector section
together, and collapsed six next-step headings into one list, bringing
build-agent.md and conclusion.md within the 3-5 H2 guidance.

Load-bearing constraints stay as positive prose: the page_url/page_urlpath
contrast, the published-groups-only picker, and the narrative column mapping.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jborlase-snowplow

Copy link
Copy Markdown
Contributor Author

Pushed c8e55994 — owner-lens edit round, same shape as the Vercel PR: Micro panel out, Ask the Snowplow Assistant section leading the configuration page, rationale/duplication cuts, positive troubleshooting, build-agent.md 7→5 H2s and conclusion.md collapsed to a single Next steps section. One code knock-on: the verification log line now prints section count only (the byte-count output it documented was a verification artifact). Same #1884 merge-order note as the Vercel PR.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants