Skip to content

Stamp metadata.anthropic_cookbook on managed-agent deploys#245

Merged
mihilmy merged 1 commit into
anthropics:mainfrom
dlaw-ant:dlaw/cookbook-attribution
May 21, 2026
Merged

Stamp metadata.anthropic_cookbook on managed-agent deploys#245
mihilmy merged 1 commit into
anthropics:mainfrom
dlaw-ant:dlaw/cookbook-attribution

Conversation

@dlaw-ant
Copy link
Copy Markdown
Contributor

Adds metadata.anthropic_cookbook = "<repo-slug>/<cookbook-dir>" to every POST /v1/agents body 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_created canonical log. anthropics/anthropic#498619 (merged) taught EmitSessionConfigLog to emit this one reserved key; anthropics/dbt#9530 surfaces it as managed_agents_sessions.anthropic_cookbook. Without this stamp, cookbook sessions are indistinguishable from any other Managed Agents session.

What changed:

  • REPO_SLUG derived from git config --get remote.origin.url (override via env) so the script stays copy-identical across vertical repos.
  • COOKBOOK_TAG="${REPO_SLUG}/${ROLE}"ROLE is the script's existing $1 cookbook-dir arg.
  • One jq merge in create_agent() injects {anthropic_cookbook: $COOKBOOK_TAG} into .metadata (preserving any existing metadata keys). Applies to orchestrator and all subagents, and shows in --dry-run output.
  • Echo the tag alongside the agent id on success.

Value format: <repo-slug>/<cookbook-dir> — e.g. financial-services/gl-reconciler. Matches the SanitizeAnthropicCookbook regex gate in api-go (^[a-z0-9._/-]{1,128}$).

Validation:

scripts/deploy-managed-agent.sh gl-reconciler --dry-run | jq '.[].metadata'
# → {"anthropic_cookbook":"financial-services/gl-reconciler"}

@mihilmy mihilmy marked this pull request as ready for review May 21, 2026 02:31
@mihilmy mihilmy merged commit 96bc961 into anthropics:main May 21, 2026
3 checks passed
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.

2 participants