Skip to content

Refactor session creation and imports in SKILL.md#1323

Open
jamesmontemagno wants to merge 11 commits intogithub:mainfrom
jamesmontemagno:patch-3
Open

Refactor session creation and imports in SKILL.md#1323
jamesmontemagno wants to merge 11 commits intogithub:mainfrom
jamesmontemagno:patch-3

Conversation

@jamesmontemagno
Copy link
Copy Markdown
Contributor

Refactor session creation in Python and Go examples to use keyword arguments for clarity. Update imports to match new structure.

Pull Request Checklist

  • I have read and followed the CONTRIBUTING.md guidelines.
  • I have read and followed the Guidance for submissions involving paid services.
  • My contribution adds a new instruction, prompt, agent, skill, or workflow file in the correct directory.
  • The file follows the required naming convention.
  • The content is clearly structured and follows the example format.
  • I have tested my instructions, prompt, agent, skill, or workflow with GitHub Copilot.
  • I have run npm start and verified that README.md is up to date.
  • I am targeting the staged branch for this pull request.

Description


Type of Contribution

  • New instruction file.
  • New prompt file.
  • New agent file.
  • New plugin.
  • New skill file.
  • New agentic workflow.
  • Update to existing instruction, prompt, agent, plugin, skill, or workflow.
  • Other (please specify):

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.

github-actions bot and others added 11 commits April 1, 2026 23:04
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
…sdk-0.2.1"

This reverts commit d14dc51, reversing
changes made to 7c6c0be.
…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.
Copilot AI review requested due to automatic review settings April 7, 2026 17:20
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This PR targets 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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_session examples to use keyword arguments and updates PermissionHandler imports.
  • Refactors Go examples to pass context.Context into Start, CreateSession, and SendAndWait.
  • 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 PermissionHandler from copilot.session, but the rest of the repository’s Python Copilot SDK examples import it from copilot. 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 PermissionHandler from copilot.session, which differs from other Python Copilot SDK documentation in this repo that imports it from copilot. 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 PermissionHandler from copilot.session, but other Python Copilot SDK examples in the repo import it from copilot. 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 a prompt key. If send_and_wait does 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 use MessageOptions(prompt=...) or { "prompt": ... } for send_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 the prompt field unless the SDK explicitly supports string prompts.
        await session.send_and_wait(user_input)
  • Files reviewed: 1/1 changed files
  • Comments generated: 3

Comment on lines +596 to +599
"type": "stdio",
"command": "npx",
"args": []string{"-y", "@modelcontextprotocol/server-filesystem", "."},
"tools": []string{"*"},
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"type": "stdio",
"command": "npx",
"args": []string{"-y", "@modelcontextprotocol/server-filesystem", "."},
"tools": []string{"*"},
Type: "stdio",
Command: "npx",
Args: []string{"-y", "@modelcontextprotocol/server-filesystem", "."},
Tools: []string{"*"},

Copilot uses AI. Check for mistakes.
Comment on lines +72 to +73
from copilot import CopilotClient
from copilot.session import PermissionHandler
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Suggested change
from copilot import CopilotClient
from copilot.session import PermissionHandler
from copilot import CopilotClient, PermissionHandler

Copilot uses AI. Check for mistakes.
on_permission_request=PermissionHandler.approve_all,
model="gpt-4.1",
)
response = await session.send_and_wait("What is 2 + 2?")
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Suggested change
response = await session.send_and_wait("What is 2 + 2?")
response = await session.send_and_wait({"prompt": "What is 2 + 2?"})

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-lease

If that does not resolve it, you can run npm run plugin:clean which will delete the materialised plugins and you can commit that change.

@github-actions github-actions bot force-pushed the main branch 11 times, most recently from 5b5010d to 43228b9 Compare April 9, 2026 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants