forked from github/copilot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (42 loc) · 1.7 KB
/
Copy pathmain.py
File metadata and controls
53 lines (42 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import asyncio
from copilot import CopilotClient
from copilot.tools import Tool
async def analyze_handler(args):
return f"Analysis result for: {args.get('query', '')}"
async def main():
client = CopilotClient()
try:
session = await client.create_session(
model="claude-haiku-4.5",
tools=[
Tool(
name="analyze-codebase",
description="Performs deep analysis of the codebase",
handler=analyze_handler,
parameters={
"type": "object",
"properties": {"query": {"type": "string"}},
},
),
],
default_agent={"excluded_tools": ["analyze-codebase"]},
custom_agents=[
{
"name": "researcher",
"display_name": "Research Agent",
"description": "A research agent that can only read and search files, not modify them",
"tools": ["grep", "glob", "view", "analyze-codebase"],
"prompt": "You are a research assistant. You can search and read files but cannot modify anything. When asked about your capabilities, list the tools you have access to.",
},
],
on_permission_request=lambda _: {"action": "allow"},
)
response = await session.send_and_wait(
"What custom agents are available? Describe the researcher agent and its capabilities."
)
if response:
print(response.data.content)
await session.disconnect()
finally:
await client.stop()
asyncio.run(main())