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

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](https://claude.com/product/claude-code) or Copilot to a [GitHub Copilot business or enterprise account](https://docs.github.com/en/copilot/tutorials/roll-out-at-scale/assign-licenses/choose-enterprise-plan) using the wonderful [agentgateway.](https://agentgateway.dev/)

## Pre-requisite - have a GitHub Copilot license:

Find out where your Copilot endpoints are:

```bash
$ 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:

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

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

```bash
export GH_COPILOT_TOKEN=$(gh auth token)
```

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

```yaml
# 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:

```shell
agentgateway -f ./config.yaml
```

CTRL+C to end.

## Test agentgateway is proxying requests to GitHub APIs

You should be able to make `curl` requests

```bash
 curl localhost:3000/models
```

Test with inference with completions and responses endpoints:

```bash
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
 }'

```

```bash
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:

![](https://cdn.hashnode.com/uploads/covers/6b1538d095f368bf9e51e4d9/922733d0-f643-4642-b862-3fa50cb4cf9d.png align="center")

## 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:

```bash
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:

```shell
$ 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:

```yaml
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:

![](https://cdn.hashnode.com/uploads/covers/6b1538d095f368bf9e51e4d9/61e397d3-1f60-4855-b9fa-a88a423fdc57.png align="center")

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

![](https://cdn.hashnode.com/uploads/covers/6b1538d095f368bf9e51e4d9/9897baa2-15ec-4e92-9e53-8b7f95853fb3.png align="center")

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](https://arize.com/phoenix/) AI observability & evaluation.
