cx-python-tools-callbacks

cx-python-tools-callbacks is a skill for Gemini CLI from GoogleCloudPlatform/professional-services. It costs 59 tokens per session (2,169 once invoked), scanned A, original, Apache-2.0.

A procedural guide for creating sandboxed Python tools and callbacks in CX Agent Studio. Tools run during a conversation, while callbacks run before an agent processes a message.

In plain words
What is it for?
Use it to add Python functions, call APIs or other tools, inspect messages, and update conversation state.
Why use it?
It provides consistent patterns for connecting tools, handling errors, reading state, and extending an agent safely.

Skill for Gemini CLI

Written for Gemini CLI: installed under .gemini/.

Good fit Use it to add Python functions, call APIs or other tools, inspect messages, and update conversation state.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/googlecloudplatform/professional-services/cx-python-tools-callbacks
About the project

Google Cloud Professional Services is a repository of example solutions and tools for building systems with Google Cloud products. Teams can use them as references or adapt them for workloads involving services such as GKE, BigQuery, Dataflow, and machine learning APIs. The catalogue entries are skills related to this repository.

GoogleCloudPlatform/professional-services · 3,090 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add GoogleCloudPlatform/professional-services --skill cx-python-tools-callbacks
Clone the repo
git clone --depth 1 https://github.com/GoogleCloudPlatform/professional-services

Made for: Gemini CLI.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cx-python-tools-callbacks

README.md
[![agentmods](https://agentmods.dev/badge/skills/googlecloudplatform/professional-services/cx-python-tools-callbacks/github.svg)](https://agentmods.dev/skills/googlecloudplatform/professional-services/cx-python-tools-callbacks)
Your own site
<a href="https://agentmods.dev/skills/googlecloudplatform/professional-services/cx-python-tools-callbacks"><img src="https://agentmods.dev/badge/skills/googlecloudplatform/professional-services/cx-python-tools-callbacks/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cx-python-tools-callbacks

Your own site · 80×15
<a href="https://agentmods.dev/skills/googlecloudplatform/professional-services/cx-python-tools-callbacks"><img src="https://agentmods.dev/badge/skills/googlecloudplatform/professional-services/cx-python-tools-callbacks.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 59 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,169 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00059 $0.02169
Opus 5.5 $0.00024 $0.00868
Sonnet 5.5 $0.00012 $0.00434
Haiku 4.5 $0.00006 $0.00217

Measured 25d ago against content hash 9fb3d9abc24f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

cx-python-tools-callbacks scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 25d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

examples/asop-studio/.gemini/skills/cx-python-tools-callbacks/SKILL.md · 220 lines

How it starts

The opening of the file, as written. The whole thing — 220 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CX Agent Studio Python Tools & Callbacks: Comprehensive Guide and Best Practices

Overview

CX Agent Studio supports extending agent functionality through sandboxed Python 3 script executions. These scripts operate in two primary contexts:

  1. Python Function Tools: Invoked by the model mid-conversation to perform computations, fetch APIs, or query data sources.
  2. Pre-agent Callbacks (beforeAgentCallbacks): Executed prior to prompt processing to perform event detection, message parsing, or prepare the conversation state.

This skill provides the strict templates, wrapper error patterns, state access paths, and registration files required to implement custom sandboxed logic without errors.

Key capabilities covered:

  • Tool Configuration Mapping: Associating a JSON tool descriptor with a python file.
  • Standard Non-Invasive Wrapper Pattern: Catching and surfacing exceptions safely in sandboxed runtimes.
  • State Manipulation: Interacting with context.state and callback_context.state.
  • Inter-Tool Execution: Calling other defined tools via the global tools instance.
  • Pre-agent Callback Architecture: Hooking into the conversation flow to inspect user messages.

Critical Rules (Always Apply)

[!IMPORTANT] Sandboxed execution environments can swallow python exceptions, returning generic errors to the agent console. Always follow the wrapper pattern to preserve tracebacks.

  • The Try/Except Wrapper Pattern is Mandatory: Never implement core tool logic directly in the entry-point function. Use a _wrapped function sibling and return tool_exception(exc) inside a catch block.
  • Meaningful Entry-Point Docstrings: CX Agent Studio feeds the entry-point function's docstring directly to the LLM as the tool's specification. It MUST clearly describe the tool's purpose and the semantic meaning of its arguments. Never use meaningless generic placeholders.
  • Do Not Alter Original Logic for Exception Handling: The wrapping structure must be a non-invasive drop-in so that reviewers can easily inspect the logic.
  • State Namespace Access: Inside sandboxed tools, access state via context.state.get(). Inside pre-execution callbacks, access state via callback_context.state[].
  • Global Tools Handler: Inter-tool calling is fully supported. Call other tools by referencing the global tools object: tools.my_other_tool_name(payload).

Read the full file on GitHub · 220 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 25d ago First seen · 220 lines · 59 tokens per session scan A 9fb3d9abc24f

Subscribe to this mod's changes

cx-python-tools-callbacks is a skill published in the GitHub repository GoogleCloudPlatform/professional-services (3,090 stars, last pushed 6d ago), licensed Apache-2.0. It adds 59 tokens to every session and 2,169 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-05.

Related

cx-python-tools-callbacks compared with skills from other repositories

cx-python-tools-callbacks next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
cx-python-tools-callbacksGoogleCloudPlatform/professional-servicesSkill3.1k6d agoApache-2.0A59Gemini CLI
matlabK-Dense-AI/scientific-agent-skillsSkill59k7d agoMITA44Claude Code
pennylaneK-Dense-AI/scientific-agent-skillsSkill59k7d agoMITA74Claude Code
holoscan-install-wheelNVIDIA/skillsSkill4.2k3d agoApache-2.0A34Claude Code, Codex
future-self-liteTHU-MAIC/OpenMAICSkill45k2d agoMITA20Claude Code, Codex
rocm-kernelshuggingface/kernelsSkill796yesterdayApache-2.0A93Claude Code
splitting-oversized-modulesPostHog/posthogSkill41ktodaynoneA197Claude Code, Codex