Automated workflows can silently inflate API bills. GitHub is tackling this head-on by optimizing its own GitHub Agentic Workflows token efficiency. These automated systems, designed to maintain code quality and perform CI tasks, run frequently and can incur significant costs without direct oversight.
Unlike interactive AI sessions, the predictable nature of YAML-defined workflows allows for systematic optimization. GitHub's engineering and security teams recognized the need to manage token usage, mirroring concerns of their user base.
Logging Token Consumption
The first step involved understanding where tokens were being spent. A challenge emerged from the inconsistent logging formats across different agent frameworks. To solve this, GitHub leveraged its API proxy, which sits between agents and authentication credentials, to capture usage data in a standardized format.
Every workflow now generates a token-usage.jsonl artifact. This log details input tokens, output tokens, cache reads/writes, model, provider, and timestamps for each API call. This data provides a historical view essential for identifying inefficiencies.
