Invantive applications detect by themselves when they run within the context of an AI agent, such as Claude Code, Codex, Cursor, Gemini CLI or GitHub Copilot. Nothing has to be configured: an agent marks the commands it runs with an environment variable, and the application reads it at start-up. The detection changes what the application shows and records. It does not change what the application does with data, which databases it reaches, or which rights apply. ## How an Agent Is Detected There is no single convention for marking a command yet. The application checks the variables below, the same list as the agent mode of the DuckDB command line. The first variable which is set and not `0` or `false` decides. | Variable | Set by | Shown as | |---|---|---| | `CLAUDECODE` | Claude Code | Anthropic (Claude Code) | | `CODEX_CI`, `CODEX_SANDBOX`, `CODEX_THREAD_ID` | Codex | OpenAI (Codex) | | `CURSOR_AGENT` | Cursor | Anysphere (Cursor) | | `GEMINI_CLI` | Gemini CLI | Google (Gemini CLI) | | `COPILOT_AGENT`, `COPILOT_CLI`, `COPILOT_AGENT_SESSION_ID` | GitHub Copilot | GitHub (GitHub Copilot) | | `AI_AGENT`, `AGENT` | Claude Code, Goose, Amp and others | the agent named in the value | `AI_AGENT` and `AGENT` are shared by several agents and carry the agent in their value, such as `claude-code_2-1-309_agent`. The part before the first underscore names the agent. An agent which is not in the list is shown as "an unknown vendor" with its code. Unlike the DuckDB command line, the detection does not depend on whether the output goes to a terminal: a window started from an agent runs within its context as well. ## What Changes - Every trace starts with the line `AI Agent`, with the agent and the variable which revealed it, or `none` (message code `itgentuy099`). A run within an agent also writes `itgenagt001` at level Info. - [[Invantive Data Hub/Invantive Data Hub|Invantive Data Hub]] prints one line before the licence check, so an agent reading the output sees it first: ``` itgendhb319 Executed within the context of an AI agent of Anthropic (Claude Code). ``` - In agent mode, Invantive Data Hub prints its results as a compact Markdown table with limits on the rows, the bytes and the characters per value, stops reading a large result early, and writes a progress line to the standard error every 5 seconds. See [[Invantive Data Hub/Command Line Options|Command Line Options]], "Layout of the Results" and "Progress of a Statement". - The log-on windows of the products with a window show a shield reading "AI" in the top left corner, level with the buttons in the top right corner. Its tooltip names the type of agent, such as "AI agent: Anthropic (Claude Code)". The shield looks the same whether the application renders light or dark. In Invantive Query Tool Multi-Platform of release 27.0 the shield stands next to the name of the product, since that window has the title bar of the operating system. ## Switching Agent Mode Off or On Running within the context of an agent is always recorded and shown, since it tells who ran a statement. Agent mode is what a product changes in its output for an agent, such as the compact tables and the progress lines of Invantive Data Hub. It is on when an agent was detected and the standard output is not a terminal. - `-no-agent`, also written `/no-agent` or `--no-agent`, switches agent mode off, such as for a person who watches the terminal of an agent or a script started from one. - `-agent` switches it on, also at a terminal. - The environment variable `INVANTIVE_AGENT_MODE` with `0` or `false` switches it off, and with `1` or `true` on, also without an agent. The command line wins over the environment variable; of `-agent` and `-no-agent` the last one wins. The trace records the switch with `itgenagt003` and on the line `AI Agent`. Available from release 27.0.55 and 27.1. ## Marking a Run for a Test Every independently started product accepts the option `-agent`, also written `/agent` or `--agent`. It marks the run as one within the context of an AI agent, as if one of the variables above were set. An agent code after a colon or an equals sign names the agent, such as `-agent:codex` or `--agent=gemini-cli`; without one, the agent is shown as unknown unless a variable names it. ``` Invantive.Producer.Data.Hub -agent:claude-code /database:Demo\Dummy /statement:"select 1" ``` The web hosts, such as Invantive UniversalSQL Server and Invantive MCP Server, remove the option before the web framework reads the command line. Invantive Composition and Invantive Control run within an Office application; the starter passes the agent on to it through `AI_AGENT`. Available from release 27.0.55 and 27.1. ## See Also - [[Run Signal]], which marks a run by hand with a text of your own. - [[Invantive Data Hub/Command Line Options|Command Line Options of Invantive Data Hub]]