Skip to content

feat(java): add Java sample ports on SDK 0.2.5 - #3

Merged
wenxinax merged 4 commits into
mainfrom
feat/java-sdk-samples
Dec 2, 2026
Merged

wenxinax merged 4 commits into
mainfrom
feat/java-sdk-samples

Conversation

@silentforce

Copy link
Copy Markdown
Contributor

Summary

Adds Java implementations for all eleven sample concepts, built against the
published Global SDK com.qoder.sdk:qoder-agent-sdk:0.2.5 from Maven Central.
TypeScript and Python samples are unchanged.

What's included

  • Eleven standalone samples: quickstart, multi-turn conversation, streaming
    chat, tool permissions, ask user question, hooks, code review, model
    selection, custom tools, subagents, and external session storage. Each has
    its own POM, README, main class, and credential-free JUnit tests, and builds
    independently when copied out of the repository.
  • Sources compile with --release 8; building requires JDK 11 or later
    (17 recommended) and Maven 3.6.3 or later.
  • A root aggregator POM and a CI job that builds on JDK 11 and 17, with Redis
    and PostgreSQL services for the session-store contract tests.
  • Both public READMEs gain a Java column and the SDK 0.2.5 compatibility
    entry; CONTRIBUTING and a Java overview document the build and runtime
    requirements.

External session storage

  • Redis and PostgreSQL adapters implement the full SessionStore contract:
    append ordering, idempotent batches, version checks, UUID conflict handling,
    per-transcript isolation, atomic writes, deletion seals, and non-blocking
    I/O. The SDK's InMemorySessionStore serves as the reference backend.
  • SessionHandoff demonstrates cross-process resume: host A remembers a
    marker, host B resumes the session in a second CLI process from the external
    store and returns it. The sample deletes only host A's closed CLI-local root
    transcript through LocalSessionHistory and forwards an explicit absolute
    QODER_CONFIG_DIR to the CLI.

SDK 0.2.5 API usage

  • An empty tools list disables built-in tools; strictMcpConfig(true)
    excludes CLI-configured MCP servers.
  • Conversation samples read each turn's result before sending the next, since
    send() now defaults to NEXT.

Verification

  • macOS arm64, JDK 11 (Temurin 11.0.32.1), Maven 3.9.16.
  • Aggregate mvn -B -ntp clean verify: 119 tests, no failures, errors, or
    skips, with local Redis 8.10.3 and PostgreSQL 17.11 enabling the
    session-store contract cases. The SDK jar resolved from Maven Central into a
    fresh local cache and matched its published SHA-1.
  • External session storage also built standalone: 46 tests passing, re-verified
    on December 1, 2026, including real handoffs on all three backends.
  • Real queries: all eleven entry points (13 runs) ran with
    QODER_PERSONAL_ACCESS_TOKEN and the SDK's managed CLI 1.1.80
    (QODERCLI_PATH unset). Each external-storage backend stored the transcript,
    resumed it in a new CLI process, returned the marker, and deleted the
    external transcript on cleanup.
  • The CI matrix (JDK 11 and 17, redis:7-alpine, postgres:17-alpine) is
    configured but was not exercised locally; local verification used JDK 11 and
    native Redis/PostgreSQL builds.

liangdong added 4 commits November 3, 2026 19:16
Add standalone Maven samples for quickstart, multi-turn conversation,
streaming chat, tool permissions, hooks, code review, and model selection.
Each sample pins com.qoder.sdk:qoder-agent-sdk:0.2.3 from Maven Central,
compiles with --release 8, and ships credential-free JUnit tests that use
only the published SDK's public API.

Register the modules in an aggregator POM and a Java CI job on JDK 11 and
17 that builds from an empty Maven cache. Document Java requirements in
CONTRIBUTING, add a Java column to both sample indexes, record the build
and runtime verification in the Java overview, and ignore Maven target
directories.
Use explicit imports grouped as SDK, JDK, and test assertions, put each
@test annotation on its own line, replace inline fully qualified names with
imports, and remove stray blank lines. No behavior change.
Add the four Java samples that were missing against TypeScript and Python:
ask user question, external session storage (Redis, PostgreSQL, and the
reference in-memory store), custom tools on the SDK 0.2.4 InProcessMcpServer
API, and subagents on SessionOptions.agents. Move every Java POM, README, and
code comment from SDK 0.2.3 to 0.2.4; the 0.2.4 public API only adds to 0.2.3
and the managed CLI stays 1.1.80.

The subagents sample exposes Read, Glob, and Grep at session level because
CLI 1.1.80 builds a subagent's tool set from the session's tools and refuses
an agent whose tool set resolves empty; the README records this difference
from the TypeScript and Python samples.

The model selection sample now validates the chosen context window and
reasoning effort against the current catalog entry and sends `--tools ""`
through a single empty tool name, because SDK 0.2.4 omits `--tools` for an
empty list.

CI starts Redis and PostgreSQL service containers for the session store
contract tests. The Java README records the November 2026 verification runs:
97 credential-free tests pass from an empty Maven cache, and all eleven
samples ran with real authentication.
Move every Java sample from SDK 0.2.4 to the published 0.2.5 core and
adapt to its API changes: an empty tools list now disables built-in
tools, strictMcpConfig(true) excludes CLI-configured MCP servers, and
conversation samples read each turn's result before sending the next
because send() now defaults to NEXT.

External session storage also adopts the new LocalSessionHistory API to
delete only host A's closed CLI-local root transcript, forwards an
explicit absolute QODER_CONFIG_DIR to the CLI, fails on late mirror
errors through MirrorErrorMessage.error(), and hardens PostgreSQL URL
handling: raw userinfo is split before percent-decoding, '+' stays
literal in database names, and connection errors no longer echo the
JDBC URL.

Update the Java overview with 0.2.5 runtime notes and the December 1
verification record, and pin SDK 0.2.5 in both public READMEs.
TypeScript and Python content remains aligned with main.

Re-verified on macOS arm64 / JDK 11 / Maven 3.9.16: the standalone
external session storage build passed all 46 tests against local Redis
8.10.3 and PostgreSQL 17.11 with a fresh Central-only Maven cache, and
the memory, Redis, and PostgreSQL backends each completed a real
handoff with the SDK's managed CLI 1.1.80 (QODERCLI_PATH unset).
@wenxinax
wenxinax merged commit 8580767 into main Dec 2, 2026
4 checks passed
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