Skip to content

Commit 411243a

Browse files
patnikoCopilot
andcommitted
fix: correct Python permission handler in steering guide
Fix all 3 Python snippets to use the correct signature: - 2-arg lambda (req, inv) matching PermissionHandlerFn typedef - Return PermissionRequestResult dataclass instead of plain dict - Add 'from copilot.types import PermissionRequestResult' import The previous pattern (lambda req: {"kind": "approved"}) would fail at runtime: TypeError from wrong arg count, and AttributeError from dict lacking .kind attribute access. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1e8ae0a commit 411243a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

docs/guides/steering-and-queueing.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ await session.send({
7070

7171
```python
7272
from copilot import CopilotClient
73+
from copilot.types import PermissionRequestResult
7374

7475
async def main():
7576
client = CopilotClient()
7677
await client.start()
7778

7879
session = await client.create_session({
7980
"model": "gpt-4.1",
80-
"on_permission_request": lambda req: {"kind": "approved"},
81+
"on_permission_request": lambda req, inv: PermissionRequestResult(kind="approved"),
8182
})
8283

8384
# Start a long-running task
@@ -228,14 +229,15 @@ await session.send({
228229

229230
```python
230231
from copilot import CopilotClient
232+
from copilot.types import PermissionRequestResult
231233

232234
async def main():
233235
client = CopilotClient()
234236
await client.start()
235237

236238
session = await client.create_session({
237239
"model": "gpt-4.1",
238-
"on_permission_request": lambda req: {"kind": "approved"},
240+
"on_permission_request": lambda req, inv: PermissionRequestResult(kind="approved"),
239241
})
240242

241243
# Send an initial task
@@ -358,7 +360,7 @@ await session.send({
358360
```python
359361
session = await client.create_session({
360362
"model": "gpt-4.1",
361-
"on_permission_request": lambda req: {"kind": "approved"},
363+
"on_permission_request": lambda req, inv: PermissionRequestResult(kind="approved"),
362364
})
363365

364366
# Start a task

0 commit comments

Comments
 (0)