Repository navigation
feat: add Message Threads examples across SDK languages - #77
Open
Arun Sekhar (achandmsft) wants to merge 2 commits into
Open
Arun Sekhar (achandmsft) wants to merge 2 commits into
Arun Sekhar (achandmsft) wants to merge 2 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Arun Sekhar (achandmsft)
requested review from
Pamela Fox (pamelafox)
and
a balanced review from Copilot
November 10, 2026 23:06
There was a problem hiding this comment.
🟢 Approval recommended
The review reports no active issues blocking approval of the opt-in Message Threads examples.
No open issues 🎉
1 file not reviewed
samples/typescript/package-lock.json: Generated file
What changed in this PR
Adds opt-in Message Threads examples across all seven SDK languages, building on the standard clients and authentication helpers from #71 to address #76. Existing Messages and streaming examples remain separate.
Changes:
- Add two-turn examples using native SDK thread helpers and existing authentication.
- Add offline tests for create/continue requests, replay, error handling and text output.
- Document usage and Foundry compatibility observations; raise Python’s SDK minimum to 2.4 and TypeScript’s pin to 1.4.0.
| File | Description |
|---|---|
tests/test_message_threads.py |
Tests Python thread requests, replay and errors. |
src/message_threads.py |
Adds the Python two-turn example. |
samples/typescript/test/message_threads.test.ts |
Tests thread requests, replay, errors and deadlines. |
samples/typescript/src/message_threads.ts |
Adds the TypeScript thread entrypoint. |
samples/typescript/src/main.ts |
Exports shared error formatting. |
samples/typescript/README.md |
Documents thread usage and tested SDK version. |
samples/typescript/package.json |
Adds the threads command and updates the SDK pin. |
samples/typescript/package-lock.json |
Locks SDK version 1.4.0. |
samples/ruby/test/message_threads_test.rb |
Tests Ruby thread behavior and failures. |
samples/ruby/README.md |
Documents thread usage and client reuse. |
samples/ruby/message_threads.rb |
Adds the Ruby executable entrypoint. |
samples/ruby/lib/claude_sample/sample.rb |
Exposes shared diagnostic helpers. |
samples/ruby/lib/claude_sample/message_threads.rb |
Implements the Ruby thread example. |
samples/README.md |
Links thread examples and compatibility guidance. |
samples/php/tests/run.php |
Registers the thread tests. |
samples/php/tests/MessageThreadsTest.php |
Tests requests, replay, authentication and diagnostics. |
samples/php/src/Sample.php |
Exposes shared credential and diagnostic helpers. |
samples/php/src/MessageThreads.php |
Implements the PHP thread example. |
samples/php/README.md |
Documents thread usage and test coverage. |
samples/php/message_threads.php |
Adds the PHP executable entrypoint. |
samples/message-threads.md |
Documents the contract, SDK versions and Foundry observations. |
samples/java/src/test/java/sample/anthropic/MessageThreadsTest.java |
Tests Java thread requests, recovery and failures. |
samples/java/src/main/java/sample/anthropic/SampleRunner.java |
Shares client lifecycle and error handling between examples. |
samples/java/src/main/java/sample/anthropic/MessageThreads.java |
Adds the Java thread entrypoint. |
samples/java/README.md |
Documents the Java thread command. |
samples/go/README.md |
Documents thread mode and its tests. |
samples/go/message_threads.go |
Implements the Go thread example. |
samples/go/message_threads_test.go |
Tests thread behavior and beta isolation. |
samples/go/main.go |
Adds and validates the -threads option. |
samples/dotnet/tests/AnthropicStandardSdk.Tests/TestSupport.cs |
Adds configurable response IDs and thread error codes. |
samples/dotnet/tests/AnthropicStandardSdk.Tests/SampleRunnerTests.Threads.cs |
Tests thread behavior, diagnostics and beta isolation. |
samples/dotnet/tests/AnthropicStandardSdk.Tests/SampleRunnerTests.cs |
Makes the test class partial for thread tests. |
samples/dotnet/src/AnthropicStandardSdk/ThreadsExample.cs |
Implements the C# thread example. |
samples/dotnet/src/AnthropicStandardSdk/SampleRunner.cs |
Adds and validates the --threads option. |
samples/dotnet/README.md |
Documents C# thread usage. |
requirements.txt |
Raises the Python Anthropic SDK minimum to 2.4.0. |
README.md |
Adds thread links, usage and the updated Python requirement. |
Review effort: Balanced
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add separate Message Threads examples for Python, TypeScript, C#, Go, Java, PHP and Ruby.
Why
Fixes #76. Stacked on #71 so this PR contains only the Threads work.
How
Foundry accepted adding/removing top-level
cache_controldespite the documented fixed-field rule; a recheck reproduced it on both models (4/4 returned200). TTL/effort changes were rejected correctly. This is a documentation-contract comparison, not a confirmed Foundry-only bug: no native Anthropic account key was available.Verification
azd upsucceeded end-to-end on a fresh env (Bicep)azd upsucceeded end-to-end on a fresh env (Terraform)python src/hello_claude.pyreturned a live model responseNo IaC changes or fresh provisioning. Live checks reused the gitignored exported Foundry profile; subscription identifiers are intentionally omitted.
GitHub validation on the latest commit: all 10 jobs passed, including all seven SDK paths.
Used local runtimes (Python from
.venv) and a cached Maven repository ($repo).python -m unittest discover -s tests -v: 68 passed;python -m compileall -q src tests: passed;python -m pip check: passednpm ci --ignore-scripts: passed, with the pre-existing advisory below;npm run build: passed;npm test: 65 passed, including type-checkdotnet test samples\dotnet\AnthropicStandardSdk.sln --configuration Release --no-restore --nologo: 133 passedgofmt -l .: clean;go vet ./...: passed;go test -count=1 ./...: 60 top-level tests passed;go mod verify: passedmvn -o -B "-Dmaven.repo.local=$repo" test: 139 passedcomposer test --no-ansi: 56 passedbundle exec ruby test\run.rb: 43 passed, 527 assertionsLive entrypoints all returned
ORCHID-47:python src\message_threads.py: passed.node src\message_threads.ts: passed.dotnet run --project samples\dotnet\src\AnthropicStandardSdk --configuration Release --no-build -- --threads: passed.go run . -threads: passed.mvn -o -q "-Dmaven.repo.local=$repo" compile exec:java "-Dexec.mainClass=sample.anthropic.MessageThreads": passed.php -d "curl.cainfo=$env:TRUSTED_CA_BUNDLE" -d "openssl.cafile=$env:TRUSTED_CA_BUNDLE" message_threads.php: passed, TLS verification enabled.ruby message_threads.rb: passed.Protocol checks passed on Opus 5.5 and Sonnet 5.5 in
eastus2: streaming continuation, tool results, replay, missing/reused IDs, fixed-field rejection and idle expiry. Python's native helper also recovered after 310 seconds idle. The basic flow passed with API versions2026-10-21and2023-06-01. The existing TypeScript Messages and--streampaths also passed live on SDK 1.4.0.Environment caveats: PHP on Windows needed a trusted CA bundle; Java emitted its existing SLF4J warning.
npm ciaudit: one pre-existing high advisory, GHSA-xcx6-jx8p-x3h5, in@azure/msal-node6.0.1 via@azure/identity4.14.0. The advisory affects MSAL's authorization-code flow, which these samples do not use. This PR changes only@anthropic-ai/sdkin the lockfile.@azure/identity4.14.1 depends on@azure/msal-node^7.1.0; that bump belongs in #71.Review follow-up: aligned the TypeScript example with
main.tsconstants and error output, removed a redundant PHP default and a long Go comment, and tightened the docs. Final Sonnet 5.5 review: no actionable issues.Checklist
infra-bicep/andinfra-terraform/(if applicable)