> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Import Gemini Managed Agents runs

> Save Gemini API Managed Agents interactions, then import them offline as self-reported agent runs.

Gemini API Managed Agents run the agent loop for you, in a Google-hosted
environment or one you host yourself. No OpenTelemetry export is documented
for them. Instead, each `Interaction` resource carries the steps and the
token usage. EvalGate reads saved interactions offline into the same
`evalgate.agent-run.v2` runs as Claude Code, so a view or report can compare
them.

> [!WARNING]
>
> This decoder is **Experimental**. It is written from Google's Interactions API
> reference and tested against a synthetic capture, not a real one. The API is
> in preview and its fields can change. It ships in the TypeScript 4.0.0 source
> candidate of `@evalgate/sdk`, which is not published yet. EvalGate never calls
> the Gemini API and never holds a Gemini key: you save the interactions
> yourself.

## 1. Save the interactions

Fetch each interaction of the task with `interactions.get` and write its JSON
on one line of a file, for example with `jq -c .`. Include every interaction
in the `previous_interaction_id` chain. The resources contain prompts,
thoughts, outputs, tool arguments and tool results; treat the file as
sensitive and delete it after the import.

## 2. Import the interactions

```bash theme={null}
npx @evalgate/sdk harness import --from ./interactions.jsonl \
  --source gemini-interactions \
  --runtime-host google_ai_studio \
  --tier light --task release-notes --apply
```

Each `previous_interaction_id` chain becomes one run, whatever order the lines
are in; `--run-id` folds every chain into one run. Use
`--runtime-host google_agent_platform` for the Managed Agents API on Agent
Platform. When you give a runtime host, the hosting comes from the
interaction's `environment` (`remote` or `mode: self_hosted`) unless you pass
`--runtime-hosting`, and the environment id is kept only as a salted digest.
EvalGate never infers the host or the sandbox provider.

## What the run contains

| Measure | Where it comes from |
| - | - |
| Input, output, cached and thought tokens | Each finished interaction's `usage`. Input includes cached tokens, so EvalGate subtracts them; `total_thought_tokens` is reported as reasoning tokens. |
| API errors | One per interaction with status `failed` or a non-empty `errors` list. |
| Tool calls and failures | Call steps counted by built-in type (`code_execution`, `google_search`, `url_context`, `file_search`, `mcp` and others) and their results' `is_error`, also when the result arrives in the next interaction. Function calls are counted as `function`; their names are never kept. |
| Repeated tool calls | Calls with identical arguments, compared by salted digest. |
| Time | From the first interaction's `created` to the last one's `updated`. |

An unfinished interaction's usage is not counted, and any interaction without
a count makes that run total `n/a` with reason `not_exported` instead of an
undercount. One interaction can hold several model calls, so API requests and
retries stay `not_exported`, as do cache writes, cost (the offline price
snapshot covers Anthropic models only), file reads and edits, subagent
measures and time waiting on a person.

Text, thoughts, signatures, tool arguments and results, error messages,
system instructions and labels are never read into the run. Interaction ids
are replaced by salted digests. Every number is self-reported by the Gemini
API and is not verified against billing data. To compare runs, continue with
[cost of quality for coding agents](/docs/guides/cost-of-quality-for-coding-agents.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.