Skip to main content

How to see what coding agents actually send: inspecting with agentgateway

Updated 3 min readMarkdown

When I first learned the web, being able to watch Apache logs and Netscape's View Source made me a better developer.

Instead of guessing why your coding agent's behaving a certain way, try inspecting the instructions, tool calls, and results behind its answer... you may be surprised.

Here's a quick guide to connect either Claude Code or Copilot to a GitHub Copilot business or enterprise account using the wonderful agentgateway.

Pre-requisite - have a GitHub Copilot license:

Find out where your Copilot endpoints are:

$ gh api /copilot_internal/user -q '.endpoints'
{
  "api": "https://api.enterprise.githubcopilot.com",
  "exp": "https://exp.enterprise.githubcopilot.com",
  "origin-tracker": "https://origin-tracker.enterprise.githubcopilot.com",
  "proxy": "https://proxy.enterprise.githubcopilot.com",
  "telemetry": "https://telemetry.enterprise.githubcopilot.com"
}

Run agentgateway

Install/upgrade agentgateway locally:

$ curl -sL https://agentgateway.dev/install | bash

In a new terminal, set your GitHub token as an env var:

export GH_COPILOT_TOKEN=$(gh auth token)

And create the agentgateway config.yaml - in our case to run on port 3000:

# yaml-language-server: $schema=https://agentgateway.dev/schema/config
gateways:
  default:
    port: 3000
    protocol: HTTP

llm:
  models:
    - name: "*"
      provider: copilot
      params:
        baseUrl: https://api.enterprise.githubcopilot.com
        apiKey: "$GH_COPILOT_TOKEN"

Run it:

agentgateway -f ./config.yaml

CTRL+C to end.

Test agentgateway is proxying requests to GitHub APIs

You should be able to make curl requests

 curl localhost:3000/models

Test with inference with completions and responses endpoints:

curl http://localhost:3000/chat/completions \
 -H "Content-Type: application/json" \
 -d '{
   "model": "claude-haiku-4.5",
   "messages": [{"role": "user", "content": "Reply with OK"}],
   "max_tokens": 32
 }'
curl http://localhost:3000/responses \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mai-code-2-flash",
    "input": "Reply with OK"
  }'

And access the admin UI on http://localhost:15000/ui where you should find access logs already there:

Connect Github Copilot CLI to agentgateway:

Now, due to the way Copilot CLI connects to models, you need to set the API format & set a model for a given launch of Copilot. In a new terminal:

export COPILOT_PROVIDER_BASE_URL="http://localhost:3000/v1"
export COPILOT_PROVIDER_TYPE="openai"
export COPILOT_PROVIDER_WIRE_API="responses"
export COPILOT_MODEL="gpt-6.1-sol"

copilot  

Important: note the /v1 on the base URL.

Connect Claude Code to agentgateway:

We can also connect Claude Code to agentgateway (assuming your Copilot license allows you select from Anthropic models). This is much simpler:

$ export ANTHROPIC_BASE_URL="http://localhost:3000"
$ export ANTHROPIC_API_KEY="dummy-key"

claude

Configure full logging:

Add agentgateway configuration to persist logs and enable full payload capture. The full config.yaml should now be:

gateways:
  default:
    port: 3000
    protocol: HTTP

llm:
  gateways:
    - default
  models:
    - name: "*"
      provider: copilot
      params:
        baseUrl: https://api.enterprise.githubcopilot.com
        apiKey: "$GH_COPILOT_TOKEN"

  policies:
    cors:
      allowOrigins:
      - http://localhost:15000
      allowHeaders:
      - '*'
      allowMethods:
      - GET
      - POST
config:
  logging:
    database:
      url: ./request-logs.sqlite
frontendPolicies:
  http:
    maxBufferSize: 33554432 
  accessLog:
    database:
      llm: full
      add:
        debug.http.request_body: 'string(request.body)'

NB: yes, this is full-payload capture - meant for local development only.

Restart agentgateway, make some new requests (via curl or your coding agent) and check the http://localhost:15000/ui/llm/logs page for metrics on each request:

Click the expandable "conversation" element to see the details:

Spend some time reading through these. Understand what the agent already receives before deciding what your skills and instructions need to add.

Next steps

In further articles, we will look at some of the things you can learn from this.

In the meantime, see this starter repo for more details, including running persisting logs to a database, and optional connecting Arize Phoenix AI observability & evaluation.

No comments yet. Be the first to comment.