Skip to content

Support request labels on Vertex calls for GCP cost attribution #142

Description

@sergodeeva

Environment

  • google-antigravity SDK v0.1.7
  • Python 3.11+
  • Linux (GitHub Actions) and macOS

Description

It would be great to attach GCP request labels to Vertex calls when running with vertex=True. Vertex AI accepts a labels map on GenerateContentRequest (docs), and those labels flow into Cloud Billing.

Today there's no way to set them, so multiple SDK-based workloads in one GCP project collapse into a single Vertex AI line item.

Evidence

The Vertex request type compiled into the harness already carries labels:

$ strings google/antigravity/bin/localharness | grep -i 'GenerateContentRequest.*Label'
...google.cloud.aiplatform.master.GenerateContentRequest.LabelsEntry...
...prediction_service_go_proto.(*GenerateContentRequest).GetLabels

But no message in the harness config proto (the Python → Go contract) exposes a labels field:

>>> import google.antigravity.connections.local.localharness_pb2 as pb
>>> from google.protobuf.message import Message
>>> [f.name for f in pb.VertexEndpoint.DESCRIPTOR.fields]
['base_url', 'http_headers', 'project', 'location', 'options']
>>> [m for m in dir(pb)
...  if isinstance(getattr(pb, m), type) and issubclass(getattr(pb, m), Message)
...  and any('label' in f.name for f in getattr(pb, m).DESCRIPTOR.fields)]
[]

And it isn't on the Python config model either:

>>> from google.antigravity.connections.local.local_connection_config import LocalAgentConfig
>>> [f for f in LocalAgentConfig.model_fields if 'label' in f]
[]

Proposed Fix

The Vertex request already accepts labels (see above); the gap is that neither the config proto nor the Python model carries them. A fix would:

  1. Add a labels map field to the harness config proto, e.g. on VertexEndpoint.
  2. Set it on GenerateContentRequest.labels for each Vertex call in the harness.
  3. Expose a labels: dict[str, str] option on the Vertex config, as a LocalAgentConfig shorthand alongside project / location.
  4. Pass it through the config-to-proto conversion so the value reaches the harness.

Workarounds

  1. Dedicated GCP project per workload — project-level attribution, but heavyweight and doesn't scale to workloads that share infrastructure.
  2. Client-side token accounting from UsageMetadata, priced offline — parallel bookkeeping that can't reconcile against the actual invoice (and metadata was historically dropped on finish/tool turns, Finish/tool turns drop SDK usage metadata while equivalent plain text turns do report it #24).
  3. Calling google-genai directly with GenerateContentConfig(labels=...) — loses the harness (skills, sandbox, policies).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions