Skip to content

Port upstream examples (PR #512) and Azure Managed Identity docs (PR #498)#36

Merged
krukow merged 7 commits intomainfrom
port-upstream-examples-and-docs
Feb 27, 2026
Merged

Port upstream examples (PR #512) and Azure Managed Identity docs (PR #498)#36
krukow merged 7 commits intomainfrom
port-upstream-examples-and-docs

Conversation

@krukow
Copy link
Collaborator

@krukow krukow commented Feb 27, 2026

Summary

Ports two upstream changes to the Clojure SDK:

New examples (upstream PR github/copilot-sdk#512)

5 new Clojure examples covering SDK features that lacked dedicated examples:

Example Feature Difficulty
file_attachments.clj File attachments with :attachments in send options Beginner
session_resume.clj Session resume with resume-session + context verification Intermediate
infinite_sessions.clj Infinite sessions with compaction thresholds Intermediate
lifecycle_hooks.clj All 6 lifecycle hooks (session start/end, pre/post tool use, etc.) Intermediate
reasoning_effort.clj Reasoning effort config ("low"/"medium"/"high"/"xhigh") Beginner

Azure Managed Identity docs (upstream PR github/copilot-sdk#498)

  • New guide: doc/auth/azure-managed-identity.md — shows how to use DefaultAzureCredential (Java Azure Identity SDK) with short-lived bearer tokens for Azure AI Foundry BYOK
  • Updated doc/auth/byok.md limitations to link to the workaround
  • Updated doc/auth/index.md and doc/index.md

Other updates

  • run-all-examples.sh — added all 5 new examples
  • examples/README.md — added Examples 12–16 with usage and walkthroughs
  • CHANGELOG.md — added entries for both upstream PRs

Validation

  • bb validate-docs passes
  • ✅ All 5 examples compile
  • ✅ 85 unit/integration tests pass (253 assertions)

Port upstream scenarios from PR #512 as Clojure examples:
- file_attachments.clj: file attachments with :attachments in send options
- session_resume.clj: session resume with resume-session
- infinite_sessions.clj: infinite sessions with compaction thresholds
- lifecycle_hooks.clj: all 6 lifecycle hooks
- reasoning_effort.clj: reasoning effort config

Port Azure Managed Identity BYOK guide from upstream PR #498:
- doc/auth/azure-managed-identity.md with Clojure examples
- Updated BYOK limitations to link to workaround
- Updated doc/auth/index.md and doc/index.md

Updated run-all-examples.sh, examples/README.md, and CHANGELOG.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 27, 2026 18:47
Copy link
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

This pull request ports two upstream changes from the Node.js copilot-sdk to the Clojure implementation: 5 new example files demonstrating SDK features (file attachments, session resume, infinite sessions, lifecycle hooks, and reasoning effort), and comprehensive documentation for Azure Managed Identity authentication with BYOK. The changes align with the project's goal of maintaining API parity with the upstream SDK while adapting idiomatically to Clojure.

Changes:

  • Added 5 new runnable examples with documentation covering previously undocumented SDK features
  • Added Azure Managed Identity authentication guide showing how to use bearer tokens with DefaultAzureCredential
  • Updated BYOK documentation to reference the Managed Identity workaround instead of listing it as unsupported

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
examples/file_attachments.clj New example demonstrating file attachment feature using :attachments in send options
examples/session_resume.clj New example showing session persistence and resume by ID
examples/infinite_sessions.clj New example demonstrating context compaction with configurable thresholds
examples/lifecycle_hooks.clj New example demonstrating all 6 lifecycle hooks (session start/end, tool use, prompts, errors)
examples/reasoning_effort.clj New example showing :reasoning-effort configuration option
run-all-examples.sh Added 5 new examples to the test script
examples/README.md Added comprehensive documentation for Examples 12-16 with usage instructions and walkthroughs; clarified that script runs 14 examples (1-9, 12-16)
doc/auth/azure-managed-identity.md New guide showing Azure Managed Identity pattern with DefaultAzureCredential and bearer token refresh (contains critical bug with duplicate .getToken call)
doc/auth/byok.md Updated limitations section to reference Managed Identity workaround instead of listing it as unsupported
doc/auth/index.md Added link to Azure Managed Identity guide in Next Steps section
doc/index.md Added Azure Managed Identity guide to authentication documentation links
CHANGELOG.md Added entries for both upstream PRs (#498 and #512) with appropriate upstream sync annotations

… README wording

- Remove duplicate .getToken call in azure-managed-identity.md
- Remove explicit destroy! in session_resume.clj (with-client handles cleanup)
- Fix example range wording in README.md (1-9 and 12-16, not 1-14)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@krukow krukow marked this pull request as ready for review February 27, 2026 19:06
Copilot AI review requested due to automatic review settings February 27, 2026 19:06
krukow and others added 2 commits February 27, 2026 11:09
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
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

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (2)

examples/lifecycle_hooks.clj:38

  • Same issue as above: hook input keys are kebab-cased. (:toolName data) will be nil; use :tool-name.
                        :on-post-tool-use
                        (fn [data _ctx]
                          (println "✅ Hook: post-tool-use —" (:toolName data))
                          (record! :on-post-tool-use data))

doc/auth/azure-managed-identity.md:55

  • The Azure Identity SDK’s TokenCredential.getToken(TokenRequestContext) returns a reactive Mono<AccessToken>, not an AccessToken. As written, get-azure-token returns a Mono and (.getToken (get-azure-token)) will fail. Block (or otherwise await) the Mono to obtain an AccessToken, then call .getToken on that value.
(defn get-azure-token
  "Obtain a short-lived bearer token from Entra ID."
  []
  (let [credential (.build (DefaultAzureCredentialBuilder.))
        context    (doto (TokenRequestContext.)
                     (.addScopes (into-array String [cognitive-services-scope])))]
    (.getToken credential context)))

(def foundry-url (System/getenv "AZURE_AI_FOUNDRY_RESOURCE_URL"))

(copilot/with-client-session [session
                              {:model "gpt-4.1"
                               :provider {:provider-type :openai
                                          :base-url (str foundry-url "/openai/v1/")
                                          :bearer-token (.getToken (get-azure-token))
                                          :wire-api :responses}}]
  (println (h/query "Hello from Managed Identity!" :session session)))

…ation

- azure-managed-identity.md: .getToken returns Mono<AccessToken>, need
  .block() then .getToken() to extract the token string
- lifecycle_hooks.clj: wire data is normalized to kebab-case, use
  :tool-name not :toolName

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
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

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

- Fix Maven coordinates in azure-managed-identity.md to use
  io.github.copilot-community-sdk/copilot-sdk-clojure
- Remove unused github.copilot-sdk.helpers require from session_resume.clj
- Update README.md bullet to reflect actual cleanup mechanism (with-client

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
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

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

BYOK accepts both API keys and bearer tokens, so 'key-based only' was
inaccurate. Reword to clarify BYOK uses static credentials you supply
but doesn't natively perform identity provider flows.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@krukow krukow merged commit 3cbf9e4 into main Feb 27, 2026
1 check passed
@krukow krukow deleted the port-upstream-examples-and-docs branch February 27, 2026 20:25
@github-actions github-actions bot mentioned this pull request Feb 27, 2026
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.

2 participants