{"data":{"slug":"github-google-skills-skills-cloud-agent-platform-tuning-management-0868155795c7","title":"Manage GenAI Tuning Jobs in Agent Platform","summary":"Use this skill to list, get, or cancel ongoing GenAI tuning jobs in the Agent Platform using the Python SDK. The skill provides read-only diagnostics and destructive actions requiring explicit confirmation.","url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-agent-platform-tuning-management-0868155795c7","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-google-skills-skills-cloud-agent-platform-tuning-management-0868155795c7","markdown_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-agent-platform-tuning-management-0868155795c7.md","download_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-agent-platform-tuning-management-0868155795c7\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before executing any commands, ensure the environment is correctly initialized by authenticating with Google Cloud and installing the required Python dependencies. Always use the `run_command` method for Python code execution and include the required attribution headers for terminal commands.","instructions":"---\nname: agent-platform-tuning-management\nmetadata:\n  version: \"1.0.2\"\n  category: AiAndMachineLearning\ndescription: >-\n  Manages GenAI tuning jobs in Agent Platform. Use this to list, get, or cancel\n  ongoing model tuning jobs. Don't use for fine-tuning models (use\n  `agent-platform-tuning`), deploying models to endpoints (use\n  `agent-platform-deploy`), or managing serving endpoints (use\n  `agent-platform-endpoint-management`).\n---\n\n# Agent Platform Tuning Management\n\nThis skill provides instructions on how to manage GenAI Tuning Jobs using the\nAgent Platform Python SDK. Use this skill when a user wants to check the status\nof their tuning runs, find an active tuning job, or cancel a job that is running\ntoo long.\n\n## Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you MUST\nread [Usage Attribution](references\/attribution.md). For commands executed\ndirectly in the terminal (never in generated scripts, Terraform, or user code),\nprefix `gcloud` with `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION` and append the\nattribution suffix to `User-Agent` headers:\n\n```text\nCLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\/1.0 (skill:agent-platform-tuning-management)\"\nUser-Agent: <existing_user_agent> agent-skills\/1.0 (skill:agent-platform-tuning-management)\n```\n\n## Safety & Confirmation Tiers (CRITICAL)\n\nBefore executing any commands on behalf of the user, you MUST adhere to the\nfollowing safety tiers based on the action requested:\n\n1.  **Tier R: Read-only (`list`, `get`)**\n    *   **Rule**: No confirmation needed. You may execute these commands\n        immediately to gather information for the user.\n2.  **Tier D: Destructive & Interruptive (`cancel`)**\n    *   **Rule**: Cancellation is a Tier D action requiring **explicit typed\n        confirmation** (e.g. \"I confirm\" or \"Yes, cancel it\").\n    *   **Required Fields in Dry-Run Confirmation Card**: Before cancelling a\n        tuning job, you MUST present a dry-run confirmation preview clearly\n        listing:\n        *   **Target Resource**: The full tuning job resource name or ID (e.g.\n            `projects\/<PROJECT_ID>\/locations\/<REGION>\/tuningJobs\/<JOB_ID>`).\n        *   **Command \/ Script**: The exact cancellation command or Python code\n            to be executed.\n        *   **Expected Effect**: Stops the ongoing tuning job; any in-progress\n            training will be halted and cannot be resumed.\n        *   Ask the user to explicitly confirm (e.g., \"Do you confirm? Please\n            reply with 'I confirm' or 'Yes, cancel it'.\").\n    *   **Same-turn restriction**: NEVER execute the cancellation in the same\n        turn as presenting the preview card. Stop immediately and wait for the\n        user to confirm in a new turn. Even if the user provided pre-emptive\n        confirmation (e.g. \"Yes, I confirm, cancel tuning job ...\") or provides\n        a corrected job ID, you MUST present the dry-run preview for that\n        specific job ID and wait for confirmation in a separate turn before\n        issuing the cancellation.\n\n## Phase 0: Environment Setup\n\n**CRITICAL**: Before running any of the Python snippets below, you MUST ensure\nthe environment is correctly initialized by following these steps:\n\n1.  **Google Cloud Authentication**: Authenticate with your Google Cloud account\n    and configure active Application Default Credentials (ADC) for Agent\n    Platform access:\n\n    ```bash\n    gcloud auth login\n    gcloud auth application-default login\n    ```\n\n2.  **Python Dependencies**: This skill needs `google-cloud-aiplatform`. Do\n    **not** create a virtual environment \u2014 it starts empty and hides packages\n    the environment already provides, forcing a redundant install. Probe, and\n    install only what is missing:\n\n    ```bash\n    python3 -c \"import vertexai\" || pip install google-cloud-aiplatform\n    ```\n\n3.  **Execution**: Run Python snippets with a plain `python3`. There is no\n    environment to activate first.\n\n## Workflow Decision Tree\n\n1.  **Information Gathering**: Do you have a Project ID and Region?\n\n    *   **No** -> You **MUST** ask the user for the missing Project ID and\n        Region in plain text, or advise them to check their gcloud\n        configuration. If neither location has this information, then ask the\n        user to provide it. Do not attempt to search random regions on your own.\n    *   **Yes** -> Proceed to Step 2.\n\n2.  **Task Type**: What does the user want to do?\n\n    *   **Find or List Jobs** -> Use the Python SDK to list tuning jobs. (Tier\n        R)\n    *   **Check Status \/ Inspect a Specific Job** -> Use the Python SDK to get\n        tuning job details. (Tier R)\n    *   **Cancel a Job** -> Ask for confirmation, then use the Python SDK to\n        cancel the tuning job. (Tier D)\n\n## Using the Python SDK\n\n> [!NOTE]\n>\n> **Resource Verification & Missing Projects\/Jobs:** If the execution of the\n> Python snippet fails because of an invalid filter (e.g., `400 Provided filter\n> is not valid`), fix or drop the `filter` parameter and re-run. If it fails\n> with an error indicating a missing or inaccessible project or job ID (`403\n> Permission Denied`, `404 Not Found`, or invalid resource ID), you **MUST**\n> inform the user that the project or tuning job does not exist or cannot be\n> accessed, prompt the user to provide a valid Project ID or Job ID, and stop\n> tool execution immediately to wait for their response (do **NOT** loop or\n> assume the resource is valid).\n\n### 1. Listing Tuning Jobs (Tier R)\n\nIf the user asks \"What tuning jobs do I have running?\" or wants to find a\nspecific job ID, always execute Python code via `run_command` (do NOT use\n`curl`). If the user gave a project ID or number, use that **exact** value\n(otherwise fall back to the configured project). Pass `page_size=20` and read\nthe first page (only page through every job if the user explicitly asks for a\ntotal count or the full list). Filter server-side when asked for running jobs\n(`state=\"JOB_STATE_RUNNING\" OR state=\"JOB_STATE_PENDING\"`) or a specific model\ndisplay name (`display_name:\"NAME\"`), print `job.tuned_model_display_name`, and\nnote when `first_page.next_page_token` is set so the 20 most recently updated\njobs are not presented as the entire history:\n\n```python\nfrom google.cloud import aiplatform_v1\n\nproject_id = \"YOUR_PROJECT_ID\"  # If the user gave a project ID\/number, use it explicitly\nregion = \"YOUR_REGION\"\nparent = f\"projects\/{project_id}\/locations\/{region}\"\n\nclient = aiplatform_v1.GenAiTuningServiceClient(\n    client_options={\"api_endpoint\": f\"{region}-aiplatform.googleapis.com\"}\n)\n\nrequest = {\n    \"parent\": parent,\n    \"page_size\": 20,\n    # Optional server-side filter, e.g.:\n    # \"filter\": 'state=\"JOB_STATE_RUNNING\" OR state=\"JOB_STATE_PENDING\"',\n}\nresponse = client.list_tuning_jobs(request=request)\nfirst_page = next(iter(response.pages), None)\nfor job in (first_page.tuning_jobs if first_page else []):\n    print(f\"Name: {job.name}\")\n    print(f\"Display Name: {job.tuned_model_display_name}\")\n    print(f\"Base Model: {job.base_model}\")\n    print(f\"State: {job.state.name}\")\nif first_page and first_page.next_page_token:\n    print(\"Note: More jobs exist beyond this first page of 20 most recently updated jobs.\")\n```\n\n### 2. Getting Details for a Specific Job (Tier R)\n\nIf the user provides a Tuning Job ID and asks for its status, always execute\nPython code via `run_command` (never use `curl`). If the user gave a project ID\nor number, use it explicitly:\n\n```python\nfrom google.cloud import aiplatform_v1\n\nproject_id = \"YOUR_PROJECT_ID\"  # If the user gave a project ID\/number, use it explicitly\nregion = \"YOUR_REGION\"\njob_id = \"YOUR_JOB_ID\"  # 19-digit ID\nname = f\"projects\/{project_id}\/locations\/{region}\/tuningJobs\/{job_id}\"\n\nclient = aiplatform_v1.GenAiTuningServiceClient(\n    client_options={\"api_endpoint\": f\"{region}-aiplatform.googleapis.com\"}\n)\n\njob = client.get_tuning_job(name=name)\nprint(f\"Name: {job.name}\")\nprint(f\"Base Model: {job.base_model}\")\nprint(f\"State: {job.state.name}\")\nprint(f\"Tuning Model: {job.tuned_model_display_name}\")\n```\n\n### 3. Canceling a Job (Tier D)\n\nIf the user explicitly requests to stop, abort, or cancel a tuning job:\n\n**Safety Check**: Follow the **Tier D (Destructive \/ Irreversible)**\nconfirmation rules in the Operation Tiers section above:\n\n-   **Never report an outcome you did not observe**: Never claim a job was\n    canceled or report a backend error without actually observing it from an API\n    call.\n-   Present the confirmation preview with **Expected Effect** conditioned on the\n    job's observed state (for active `PENDING`\/`RUNNING` jobs: stops in-progress\n    training, which cannot be resumed, without deleting the base model or\n    dataset; if the job is already in a terminal state `SUCCEEDED`, `FAILED`, or\n    `CANCELLED`, state its current terminal state explicitly and note that no\n    active training is running).\n-   Wait for explicit user confirmation in a new turn before calling\n    `client.cancel_tuning_job(name=name)` via Python (`run_command`), and report\n    the actual API response verbatim.\n\n```python\nfrom google.cloud import aiplatform_v1\n\nproject_id = \"YOUR_PROJECT_ID\"  # Use the EXACT project ID\/number the user gave\nregion = \"YOUR_REGION\"\njob_id = \"YOUR_JOB_ID\"  # 19-digit ID\nname = f\"projects\/{project_id}\/locations\/{region}\/tuningJobs\/{job_id}\"\n\nclient = aiplatform_v1.GenAiTuningServiceClient(\n    client_options={\"api_endpoint\": f\"{region}-aiplatform.googleapis.com\"}\n)\n\nclient.cancel_tuning_job(name=name)\nprint(f\"Successfully requested cancellation for {name}\")\n```\n","use_cases":["Check the status of your tuning runs","Find an active tuning job","Cancel a job that is running too long"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/google\/skills\/blob\/e3c591afe426ea585e4c21799e5199d6d47cd1be\/skills\/cloud\/agent-platform-tuning-management\/SKILL.md","source_commit":"e3c591afe426ea585e4c21799e5199d6d47cd1be","license":null,"version":null,"listing_approved_at":"2026-11-17","created_at":"2026-11-16T07:43:24.000000Z","updated_at":"2026-11-17T05:10:16.000000Z","seo_title":"Manage GenAI Tuning Jobs in Agent Platform","seo_description":"Learn how to list, get, or cancel ongoing GenAI tuning jobs using the Agent Platform Python SDK.","seo_keywords":["manage tuning jobs","list tuning jobs","cancel tuning job","check tuning job status"]}}