Stamp metadata.anthropic_cookbook on managed-agent deploys#245
Merged
Conversation
mihilmy
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
metadata.anthropic_cookbook = "<repo-slug>/<cookbook-dir>"to everyPOST /v1/agentsbody the deploy script emits, so cookbook-sourced sessions become attributable in BigQuery.Why: The agent's metadata is CMEK-excluded from the Werx→BQ mirror, so the only path to BQ is the
session_agent_config_createdcanonical log. anthropics/anthropic#498619 (merged) taughtEmitSessionConfigLogto emit this one reserved key; anthropics/dbt#9530 surfaces it asmanaged_agents_sessions.anthropic_cookbook. Without this stamp, cookbook sessions are indistinguishable from any other Managed Agents session.What changed:
REPO_SLUGderived fromgit config --get remote.origin.url(override via env) so the script stays copy-identical across vertical repos.COOKBOOK_TAG="${REPO_SLUG}/${ROLE}"—ROLEis the script's existing$1cookbook-dir arg.jqmerge increate_agent()injects{anthropic_cookbook: $COOKBOOK_TAG}into.metadata(preserving any existing metadata keys). Applies to orchestrator and all subagents, and shows in--dry-runoutput.Value format:
<repo-slug>/<cookbook-dir>— e.g.financial-services/gl-reconciler. Matches theSanitizeAnthropicCookbookregex gate in api-go (^[a-z0-9._/-]{1,128}$).Validation: