Skip to content

Commit f189203

Browse files
Copilotpelikhan
andauthored
docs: add Copilot SDK support, driver configuration, and specification guidance (#36731)
* docs: add copilot sdk support section to engines reference Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> * docs: clarify gh-aw managed SDK timeout and log-level controls Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Co-authored-by: Peli de Halleux <pelikhan@users.noreply.github.com>
1 parent 9d0810b commit f189203

2 files changed

Lines changed: 69 additions & 8 deletions

File tree

docs/src/content/docs/reference/copilot-sdk-driver-specification.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ In standalone mode, the implementation MUST enforce the following contract:
139139
| `COPILOT_SDK_URI` | Yes | SDK endpoint URI | MUST be non-empty |
140140
| `COPILOT_CONNECTION_TOKEN` | Yes | Per-run shared token generated by the harness in SDK mode | MUST be non-empty in the driver environment |
141141
| `COPILOT_MODEL` | No | Model override | OPTIONAL |
142-
| `COPILOT_SDK_SEND_TIMEOUT_MS` | No | Send timeout in milliseconds | Input SHOULD be a positive integer; default `600000`; implementations MUST fall back on invalid values |
143-
| `COPILOT_SDK_LOG_LEVEL` | No | SDK client log level | Valid values: `none`, `error`, `warning`, `info`, `debug`, `all`; invalid values MUST fall back to `warning` |
142+
| `COPILOT_SDK_SEND_TIMEOUT_MS` | No | Send timeout in milliseconds | Input SHOULD be a positive integer; gh-aw typically sets this from workflow `timeout-minutes`; default `600000`; implementations MUST fall back on invalid values |
143+
| `COPILOT_SDK_LOG_LEVEL` | No | SDK client log level | gh-aw may set this for driver runtime logging; valid values: `none`, `error`, `warning`, `info`, `debug`, `all`; invalid values MUST fall back to `warning` |
144144
| `GITHUB_WORKSPACE` | No | Working directory hint | SHOULD be used when present |
145145

146146
### 4.2 Connection Token Requirement
@@ -156,9 +156,17 @@ In SDK mode, a conforming implementation:
156156

157157
### 4.3 Timeout Environment Variable
158158

159-
`COPILOT_SDK_SEND_TIMEOUT_MS` controls maximum send wait duration for prompt completion in standalone mode. Implementations MUST treat this value as milliseconds and MUST apply the default value (`600000`) when unset, non-numeric, or non-positive.
159+
`COPILOT_SDK_SEND_TIMEOUT_MS` controls maximum send wait duration for prompt completion in standalone mode.
160160

161-
### 4.4 TypeScript Example (Non-Normative)
161+
When gh-aw hosts the driver, it generally derives and injects this variable from workflow `timeout-minutes` (exposed to the harness as `GH_AW_TIMEOUT_MINUTES`) so SDK completion stays below the step timeout budget.
162+
163+
A conforming driver implementation MUST treat `COPILOT_SDK_SEND_TIMEOUT_MS` as milliseconds and MUST apply the default value (`600000`) when unset, non-numeric, or non-positive.
164+
165+
### 4.4 Log-Level Environment Variable
166+
167+
`COPILOT_SDK_LOG_LEVEL` is the host-provided SDK client log level control. A conforming driver implementation MUST use the provided value when it is one of `none`, `error`, `warning`, `info`, `debug`, or `all`; otherwise it MUST fall back to `warning`.
168+
169+
### 4.5 TypeScript Example (Non-Normative)
162170

163171
Prerequisite: install [`@github/copilot-sdk`](https://www.npmjs.com/package/@github/copilot-sdk) in the runtime where this example executes.
164172

docs/src/content/docs/reference/engines.md

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,18 +263,71 @@ The value must be a bare filename — no directory separators, no `..`, and no s
263263
| Must start with `[A-Za-z0-9_]` | `harness.js` | `-harness.cjs` |
264264
| Must end with `.js`, `.cjs`, or `.mjs` | `wrapper.cjs` | `harness.sh` |
265265

266-
### Copilot SDK Driver Override (`copilot-sdk-driver`)
266+
### Copilot SDK Support
267267

268-
When `engine.copilot-sdk: true` is enabled, gh-aw runs a Node.js driver script (`copilot_sdk_driver.cjs`) under the harness. Use `engine.copilot-sdk-driver` to replace that built-in SDK driver with your own script filename.
268+
Enable `engine.copilot-sdk: true` to run Copilot in SDK mode.
269+
In this mode, the harness starts a local sidecar and runs the
270+
SDK driver process instead of the default CLI-only flow.
271+
272+
Use `engine.copilot-sdk-driver` to replace the built-in
273+
`copilot_sdk_driver.cjs` implementation:
269274

270275
```yaml wrap
271276
engine:
272277
id: copilot
273278
copilot-sdk: true
274-
copilot-sdk-driver: custom_copilot_sdk_driver.cjs
279+
copilot-sdk-driver: custom-copilot-driver
275280
```
276281

277-
`copilot-sdk-driver` follows the same filename safety rules as `harness`: it must be a bare filename ending with `.js`, `.cjs`, or `.mjs` (no paths, no `..`, no shell metacharacters).
282+
`copilot-sdk-driver` must be a safe basename (no path
283+
separators, `..`, or shell metacharacters). It supports:
284+
285+
- script filenames ending with `.js`, `.cjs`, `.mjs`,
286+
`.py`, `.ts`, `.mts`, or `.rb`
287+
- bare command names without an extension (resolved from
288+
`PATH`)
289+
290+
See [Copilot SDK Driver Specification](/gh-aw/reference/copilot-sdk-driver-specification/)
291+
for the full driver contract.
292+
293+
#### SDK driver environment variables
294+
295+
The specification defines the driver environment contract.
296+
In SDK mode, gh-aw injects required runtime values:
297+
298+
- `GH_AW_PROMPT`
299+
- `COPILOT_SDK_URI`
300+
- `COPILOT_CONNECTION_TOKEN`
301+
302+
`COPILOT_MODEL` is optional and follows normal Copilot model
303+
configuration.
304+
305+
For runtime controls, the driver should consume:
306+
307+
- `COPILOT_SDK_SEND_TIMEOUT_MS`
308+
- `COPILOT_SDK_LOG_LEVEL`
309+
310+
In gh-aw, `COPILOT_SDK_SEND_TIMEOUT_MS` is usually injected
311+
automatically from workflow `timeout-minutes` (via
312+
`GH_AW_TIMEOUT_MINUTES`) with safety headroom. Override it in
313+
`engine.env` only when you need a custom SDK send timeout.
314+
`COPILOT_SDK_LOG_LEVEL` is a host-provided driver control and
315+
should be honored when gh-aw passes it to the driver process.
316+
317+
Do not set `COPILOT_CONNECTION_TOKEN` manually. The harness
318+
generates it per run and passes the same token to both the
319+
sidecar and driver process.
320+
321+
```yaml wrap
322+
engine:
323+
id: copilot
324+
copilot-sdk: true
325+
copilot-sdk-driver: my_driver.ts
326+
model: gpt-5
327+
env:
328+
COPILOT_SDK_SEND_TIMEOUT_MS: "900000"
329+
COPILOT_SDK_LOG_LEVEL: info
330+
```
278331

279332
### Bare Mode (`bare`)
280333

0 commit comments

Comments
 (0)