Refactor session creation and imports in SKILL.md#1323
Refactor session creation and imports in SKILL.md#1323jamesmontemagno wants to merge 11 commits intogithub:mainfrom
Conversation
Add complete Java cookbook matching the pattern of existing .NET, Go, Node.js, and Python cookbooks. All 7 recipes included: - Ralph Loop: Autonomous AI task loops with JBang - Error Handling: try-with-resources, ExecutionException, timeouts - Multiple Sessions: Parallel sessions with CompletableFuture - Managing Local Files: AI-powered file organization - PR Visualization: Interactive PR age charts - Persisting Sessions: Save/resume with custom IDs - Accessibility Report: WCAG reports via Playwright MCP Each recipe includes both markdown documentation and a standalone JBang-runnable Java file in recipe/.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Replace Thread.sleep with sendAndWait in PRVisualization - Fix top-level statements in multiple-sessions.md (wrap in class) - Fix .getMessage() → .getData().content() in MultipleSessions.java - Guard against null readLine() in AccessibilityReport.java - Add null-safe getCause() + InterruptedException handling in ErrorHandling.java - Fix paths: jbang commands now include recipe/ prefix - Fix root README path: cd java/recipe (not java/cookbook/recipe) - Fix recipe/README.md ralph-loop CLI example
Add Java SDK cookbook with 7 recipes
Fix compilation errors and documentation inaccuracies in Java cookbook recipes against the actual SDK API: - MultipleSessions: Replace non-existent destroy() with close() - AccessibilityReport: Replace non-existent McpServerConfig class with Map<String, Object> (the actual type accepted by setMcpServers) - error-handling.md: Replace non-existent session.addTool(), ToolDefinition.builder(), and ToolResultObject with actual SDK APIs (ToolDefinition.create(), SessionConfig.setTools(), CompletableFuture<Object> return type) All 7 recipes now compile successfully with jbang build. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fix: Java cookbook recipes to compile with copilot-sdk-java 0.2.1-java.1
…main revert: Remove Java cookbook from main (was merged to wrong branch)
Refactor session creation in Python and Go examples to use keyword arguments for clarity. Update imports to match new structure.
There was a problem hiding this comment.
main, but PRs should target staged.
The main branch is auto-published from staged and should not receive direct PRs.
Please close this PR and re-open it against the staged branch.
You can change the base branch using the Edit button at the top of this PR,
or run: gh pr edit 1323 --base staged
There was a problem hiding this comment.
Pull request overview
Updates the Copilot SDK skill documentation to reflect newer session-creation patterns (Python keyword arguments; Go context.Context) and expands MCP server configuration examples.
Changes:
- Refactors Python
create_sessionexamples to use keyword arguments and updatesPermissionHandlerimports. - Refactors Go examples to pass
context.ContextintoStart,CreateSession, andSendAndWait. - Adds new MCP Server Integration documentation including local filesystem (stdio) and remote HTTP + headers examples across languages.
Show a summary per file
| File | Description |
|---|---|
| skills/copilot-sdk/SKILL.md | Updates Python/Go session creation examples and adds expanded MCP server integration snippets. |
Copilot's findings
Comments suppressed due to low confidence (7)
skills/copilot-sdk/SKILL.md:680
- The Go remote MCP server snippet uses quoted keys ("type", "url", "headers", "tools") inside the copilot.MCPServerConfig literal, which is invalid Go syntax for a struct literal and won’t compile. Use the MCPServerConfig field names (e.g., Type, URL, Headers, Tools) consistent with other Go examples in this repo (e.g., plugins/copilot-sdk/skills/copilot-sdk/SKILL.md).
MCPServers: map[string]copilot.MCPServerConfig{
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": map[string]string{
"Authorization": "Bearer " + os.Getenv("GITHUB_TOKEN"),
},
"tools": []string{"*"},
skills/copilot-sdk/SKILL.md:182
- The Python example imports
PermissionHandlerfromcopilot.session, but the rest of the repository’s Python Copilot SDK examples import it fromcopilot. To avoid conflicting guidance and potential import errors, align this import with the established pattern or update related docs simultaneously.
from copilot import CopilotClient
from copilot.session import PermissionHandler
from copilot.generated.session_events import SessionEventType
skills/copilot-sdk/SKILL.md:309
- This Python snippet imports
PermissionHandlerfromcopilot.session, which differs from other Python Copilot SDK documentation in this repo that imports it fromcopilot. Please align to a single import path (and update other docs if the module layout changed).
from copilot import CopilotClient
from copilot.session import PermissionHandler
from copilot.tools import define_tool
skills/copilot-sdk/SKILL.md:494
- This Python snippet imports
PermissionHandlerfromcopilot.session, but other Python Copilot SDK examples in the repo import it fromcopilot. For consistency (and to avoid broken copy/paste), align the import path or update the other documentation files in the same PR.
from copilot import CopilotClient
from copilot.session import PermissionHandler
from copilot.tools import define_tool
skills/copilot-sdk/SKILL.md:202
- This example calls
await session.send_and_wait("Tell me a short joke"), but other Python Copilot SDK examples in this repo pass MessageOptions or a dict with apromptkey. Ifsend_and_waitdoes not accept a plain string, this snippet will be incorrect—please align with the repo’s documented usage or update the other docs to match the new API.
await session.send_and_wait("Tell me a short joke")
skills/copilot-sdk/SKILL.md:342
- This snippet uses
await session.send_and_wait("What's the weather like in Seattle and Tokyo?"). Other Python Copilot SDK docs in this repo useMessageOptions(prompt=...)or{ "prompt": ... }forsend_and_wait. If string prompts aren’t supported, update this to the documented shape (or update the rest of the docs to match).
await session.send_and_wait("What's the weather like in Seattle and Tokyo?")
skills/copilot-sdk/SKILL.md:539
- The interactive loop calls
await session.send_and_wait(user_input)with a raw string. To keep the documentation consistent (and to match the rest of the repo’s Python examples), pass MessageOptions or a dict containing thepromptfield unless the SDK explicitly supports string prompts.
await session.send_and_wait(user_input)
- Files reviewed: 1/1 changed files
- Comments generated: 3
| "type": "stdio", | ||
| "command": "npx", | ||
| "args": []string{"-y", "@modelcontextprotocol/server-filesystem", "."}, | ||
| "tools": []string{"*"}, |
There was a problem hiding this comment.
The Go MCPServers example uses quoted keys (e.g., "type", "command") inside a copilot.MCPServerConfig composite literal. In Go, struct literal field keys must be identifiers (e.g., Type, Command), so this snippet will not compile as written. Update the config literal to use the actual MCPServerConfig struct fields (matching the existing Type/URL usage elsewhere) or explicitly make the value a map type if that’s the intended API.
This issue also appears on line 673 of the same file.
| "type": "stdio", | |
| "command": "npx", | |
| "args": []string{"-y", "@modelcontextprotocol/server-filesystem", "."}, | |
| "tools": []string{"*"}, | |
| Type: "stdio", | |
| Command: "npx", | |
| Args: []string{"-y", "@modelcontextprotocol/server-filesystem", "."}, | |
| Tools: []string{"*"}, |
| from copilot import CopilotClient | ||
| from copilot.session import PermissionHandler |
There was a problem hiding this comment.
This skill switches the Python import to from copilot.session import PermissionHandler, but other Copilot SDK Python docs/instructions in this repo consistently import PermissionHandler from copilot (e.g., cookbook/copilot-sdk/python/error-handling.md and instructions/copilot-sdk-python.instructions.md). Unless the package structure has changed everywhere, this example is likely to break or create inconsistency—consider keeping from copilot import PermissionHandler here or updating the rest of the repo docs in the same PR.
This issue also appears in the following locations of the same file:
- line 180
- line 307
- line 492
| from copilot import CopilotClient | |
| from copilot.session import PermissionHandler | |
| from copilot import CopilotClient, PermissionHandler |
| on_permission_request=PermissionHandler.approve_all, | ||
| model="gpt-4.1", | ||
| ) | ||
| response = await session.send_and_wait("What is 2 + 2?") |
There was a problem hiding this comment.
session.send_and_wait() is shown being called with a bare string prompt. Elsewhere in this repo’s Python Copilot SDK docs, send_and_wait is called with a MessageOptions instance or a dict containing {"prompt": ...} (e.g., cookbook/copilot-sdk/python/error-handling.md). If the API still expects MessageOptions/dict, this example will fail—consider using the established call shape for consistency.
This issue also appears in the following locations of the same file:
- line 202
- line 342
- line 539
| response = await session.send_and_wait("What is 2 + 2?") | |
| response = await session.send_and_wait({"prompt": "What is 2 + 2?"}) |
aaronpowell
left a comment
There was a problem hiding this comment.
It looks like you've incorrectly branched from the main branch not staged, and as a result all the materialised plugins are included in this PR.
You can attempt to fix this with a rebase:
git fetch origin staged
git rebase --onto origin/staged origin/main <branch name>
git push --force-with-leaseIf that does not resolve it, you can run npm run plugin:clean which will delete the materialised plugins and you can commit that change.
5b5010d to
43228b9
Compare
Refactor session creation in Python and Go examples to use keyword arguments for clarity. Update imports to match new structure.
Pull Request Checklist
npm startand verified thatREADME.mdis up to date.stagedbranch for this pull request.Description
Type of Contribution
Additional Notes
By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.