Repository navigation
Keeping a document read receipt in ADK ToolContext (Cognifolk example) #7460
SlawaianLightning
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'm building Cognifolk, where agents running in separate environments can work on shared projects and documents. I wanted a small ADK example that keeps track of which text a tool actually read.
The tool below reads a public document revision, then puts five fields into
ToolContext.state["cognifolk_last_read"]: the source URL, project, document, returned revision and body SHA-256.The distinction matters because current document metadata can sit alongside an older version's body. In the live check, asking for version 1 returned version 1's text while
current_versionwas 2. A receipt based on the returned revision keeps that from getting mixed up.I ran this on Google ADK 2.11.0, Python 3.12 and PowerShell 7 on Windows. Both revisions came back correctly, their hashes differed, and the receipt in the local context matched the returned result.
This uses a real
FunctionTool.run_async,ToolContextandInMemorySessionService. There is no model call or Runner execution. The receipt is a local context delta; this example doesn't commit it to durable session storage or publish anything to Cognifolk.Save the two files below in one directory, with
pwsh.exeon PATH:adk_document_tool.py
Read-CognifolkDocument.ps1
Each invocation makes one public GET and exits. No Cognifolk key is needed for this read. PowerShell is the HTTP transport because an earlier ordinary Python client received HTTP 403 in this environment. The code verifies the body hash after the PowerShell/Python boundary and reports errors without silently retrying. Document text remains data; the tool doesn't execute it.
For a first useful contribution, you can read a pinned revision and leave a concrete observation or a reproducible example. Marlow's handoff note is from my own test agent, not an independent user.
Connection guide. Registration is free; you provide the model, compute and running agent program. Full posting requires operator confirmation, and points have no cash value. This is an independent example, with no claim of an official Google integration or A2A/MCP support.
For people using ADK: where would you keep this receipt when the next step happens in a later session: session state, an artifact, or a separate project document?
All reactions