[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-108776":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":15,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":20,"hasPages":20,"topics":22,"createdAt":10,"pushedAt":27,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":16,"starSnapshotCount":16,"syncStatus":31,"lastSyncTime":32,"discoverSource":33},108776,"spring-agent-scope","sinabs\u002Fspring-agent-scope","sinabs","A Spring Boot agent harness built on AgentScope Java 2.0 and JDK 25: multi-turn chat over HTTP, a fresh agent per request, shared session history.","",null,"Java",99,3,53,1,0,46,46.91,"Apache License 2.0",false,"main",[23,24,25,26],"agentscope2","ai-agent","java","spring-boot-4","2026-11-13 02:16:49","2026-11-20 07:20:18","\u003Cp align=\"center\">\u003Cimg src=\"docs\u002Fbrand\u002Flogo.svg\" width=\"160\" alt=\"Yoke Logo\">\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fsinabs\u002Fspring-agent-scope\u002Factions\u002Fworkflows\u002Fgradle.yml\">\u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Fsinabs\u002Fspring-agent-scope\u002Factions\u002Fworkflows\u002Fgradle.yml\u002Fbadge.svg\" alt=\"Build Status\">\u003C\u002Fa>\n\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FJava-25-orange\" alt=\"Java 25\">\n\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSpring%20Boot-4.1-6DB33F\" alt=\"Spring Boot 4.1\">\n\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FAgentScope%20Java-2.0-5B6BFF\" alt=\"AgentScope Java 2.0\">\n\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FGradle-9.8-02303A\" alt=\"Gradle 9.8\">\n\u003Ca href=\"LICENSE\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-Apache%202.0-blue\" alt=\"License\">\u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">English | \u003Ca href=\"README_CN.md\">简体中文\u003C\u002Fa>\u003C\u002Fp>\n\n## About Yoke\n\n**Yoke** · AgentHarness: a monolithic agent service built on Spring Boot and [AgentScope Java](https:\u002F\u002Fgithub.com\u002Fagentscope-ai\u002Fagentscope-java) (V2).\n\n> A Spring-based agent harness.\n\nYoke is an open-source project of 友客AI (YouKe AI). We read the AgentScope Java V2 and Spring source code together and learn by building an agent service that really runs. A yoke is the wooden frame that makes oxen and horses pull in one direction. Yoke wraps around the model and keeps it working reliably.\n\n- Building an agent with AgentScope Java: the demo runs in a dozen lines. Serving real users is where it gets hard. Should each request get a new agent, or share one global agent? Where does the conversation history live?\n- Streaming, tool calls, multi-turn sessions and tight permissions are scattered across the official examples. Fitting them into one Spring Boot project, deciding how to layer it and which boundaries must hold, is left to you.\n- The official starters are one line away, but their endpoints have no authentication and the agent is a singleton, so shipping them as they are mixes sessions of different users. This project gives a judgement on what to use and what to write yourself.\n- The project starts from an endpoint that can hold a conversation and solves one engineering problem per lesson. The code is open source and runs as is. Limits that were not verified and pitfalls hit along the way are written down too.\n\n### Features\n\n- One endpoint for multi-turn conversations: `POST \u002Fapi\u002Fchat`, plus `POST \u002Fapi\u002Fchat\u002Fstream` that streams the reasoning process over SSE using the AG-UI protocol.\n- A built-in `get_weather` tool looks up current weather through the open-source [Open-Meteo](https:\u002F\u002Fopen-meteo.com) API, no key needed (the free tier is for non-commercial use only).\n- Every request builds a temporary `HarnessAgent` and closes it afterwards. Conversation history lives in Redis, so it survives restarts and is shared by all replicas, isolated per `(userId, sessionId)`, and compacted automatically when a conversation gets long.\n- Apart from `get_weather` the agent has no tools: no file, shell or web access, and sub-agents are switched off. A logging middleware records a timing trace for every call.\n- Models are plugged in through the official AgentScope starters: OpenAI-compatible APIs (works with DashScope, DeepSeek and others), Anthropic, Gemini and Ollama. Switching is a dependency and configuration change.\n- `local` \u002F `test` \u002F `prod` profiles. In production, a missing API key fails the startup instead of shipping with an empty key.\n- Virtual threads are enabled by default, for both Tomcat and Spring's default thread pool.\n\n## Getting Started\n\nRequires JDK 25 and Docker (for the local Redis).\n\n```bash\ndocker compose up -d            # start Redis first; the app refuses to start without it\nsdk env                         # switch to JDK 25 (if you use sdkman)\nexport ARK_API_KEY=...          # the local profile talks to Volcengine Ark (OpenAI-compatible)\n.\u002Fgradlew bootRun               # the local profile is active by default\n```\n\n```bash\ncurl -X POST localhost:8080\u002Fapi\u002Fchat \\\n  -H 'Content-Type: application\u002Fjson' \\\n  -d '{\"message\": \"Hello\"}'\n# {\"sessionId\":\"…\",\"reply\":\"…\"}\n```\n\nSend the returned `sessionId` with later requests to continue the same conversation. Run the tests with `.\u002Fgradlew build`; tests that need a real Redis start it from the same `docker-compose.yml` through Testcontainers, and are skipped with a clear reason when Docker is not available (with `CI=true` they fail instead).\n\n### Sessions\n\nHistory is stored per `(userId, sessionId)`. Both are optional in the request body (`{\"userId\": \"alice\", \"sessionId\": \"s-1\", \"message\": \"Hello\"}`), and the server always makes sure both have a value before the agent sees them:\n\n- both given: that pair\n- only `sessionId`: it belongs to the `default` user (same as older clients)\n- only `userId`: a new session is created for that user, and its id is returned in the response\n- neither: a new session under the `default` user\n\nA half-empty pair is never passed on to the framework, because in AgentScope 2.0.4 a missing `sessionId` falls into one shared session named after the agent, and a missing `userId` falls into an anonymous user, which would mix everyone's history together. Both ids may only contain letters, digits, `_`, `.` and `-` (1 to 64 characters, not all dots, so `.` and `..` are rejected); anything else returns 400. The framework joins them as `userId\u002FsessionId`, so allowing `\u002F` would let different pairs collide on one slot, and `userId` also becomes a workspace directory name. There is no authentication yet: `userId` is whatever the caller says, so it is not an identity check.\n\nWhat is stored in Redis, per session (checked against a real model, two turns with one tool call):\n\n| Key | Type | Content |\n|---|---|---|\n| `yoke:session:{userId}\u002F{sessionId}:agent_state` | String | One JSON document with the whole agent state. The conversation is its `context` array (one entry per message: `USER`, `ASSISTANT` with `tool_use`, `TOOL` with `tool_result`, ...), next to a `summary` field and a few empty context objects. `summary` stayed empty in a real compaction run: the compaction summary is stored as the first message of `context` instead. About 3.3 KB for two turns |\n| `yoke:session:{userId}\u002F{sessionId}:agent_state:ver` | String | Version number used for optimistic concurrency, bumped on every save |\n| `yoke:session:{userId}\u002F{sessionId}:_keys` | Set | Names of all state keys of the session (only `agent_state` here), used to delete a whole session |\n\nThe model's `thinking` blocks and per-message token usage are stored too, and the whole document is read and written back on every turn, so it grows with the conversation. There is no separate message list key.\n\n\n### Streaming (AG-UI)\n\n`POST \u002Fapi\u002Fchat\u002Fstream` speaks the [AG-UI](https:\u002F\u002Fdocs.ag-ui.com\u002Fconcepts\u002Fevents) protocol: the request body is a standard `RunAgentInput`, and the response is a `text\u002Fevent-stream` of AG-UI events pushed while the agent is reasoning. Use `curl -N` to turn off buffering:\n\n```bash\ncurl -N -X POST localhost:8080\u002Fapi\u002Fchat\u002Fstream \\\n  -H 'Content-Type: application\u002Fjson' \\\n  -d '{\"threadId\": \"demo\", \"runId\": \"run-1\", \"messages\": [{\"id\": \"msg-1\", \"role\": \"user\", \"content\": \"What is the weather in Beijing?\"}]}'\n```\n\nRequest rules (any violation returns 400 before the stream starts):\n\n- `Content-Type` must be `application\u002Fjson`, otherwise 415. This also stops a cross-site page from starting a run with a `text\u002Fplain` request that skips the CORS preflight\n- `threadId` is the session ID and is required: letters, digits and `_.-`, 1 to 64 characters, not all dots. It shares the same history as `sessionId` of `POST \u002Fapi\u002Fchat` of the `default` user (`RunAgentInput` has no user field, so the streaming endpoint always runs as `default`)\n- `runId` is required and must not be blank (`RunAgentInput` requires it)\n- `messages` must not be empty, every message needs an `id` and a `role`, and the last one must be a `user` message with non-blank plain text. `content` must be a string: content blocks (even text-only ones, or with images) are rejected\n- The server keeps the history itself and only uses the **last** `user` message. Earlier messages, `tools`, `context`, `state`, `forwardedProps` and `resume` are ignored, so a client cannot add tools to the agent or rewrite the history. Only the text of that message is kept: its `id`, `toolCalls` and `toolCallId` never reach the history, and the message ID is generated on the server. The adapter is also configured with `ToolMergeMode.AGENT_ONLY`, so only server-registered tools are ever used\n\nIllustrative output (values are made up, field names come from real runs against a stub model, long fields are elided). Only `data:` lines are sent; the event type is the `type` field in the JSON, there is no SSE `event:` name:\n\n```\ndata:{\"type\":\"RUN_STARTED\",\"threadId\":\"demo\",\"runId\":\"…\",\"input\":{…}}\n\ndata:{\"type\":\"TOOL_CALL_START\",\"threadId\":\"demo\",\"runId\":\"…\",\"toolCallId\":\"call_1\",\"toolCallName\":\"get_weather\"}\n\ndata:{\"type\":\"TOOL_CALL_ARGS\",\"threadId\":\"demo\",\"runId\":\"…\",\"toolCallId\":\"call_1\",\"delta\":\"{\\\"city\\\":\\\"Beijing\\\"}\"}\n\ndata:{\"type\":\"TOOL_CALL_END\",\"threadId\":\"demo\",\"runId\":\"…\",\"toolCallId\":\"call_1\"}\n\ndata:{\"type\":\"TOOL_CALL_RESULT\",\"threadId\":\"demo\",\"runId\":\"…\",\"toolCallId\":\"call_1\",\"content\":\"\\\"Sunny, 25 C\\\"\",\"role\":\"tool\",\"messageId\":\"…\"}\n\ndata:{\"type\":\"TEXT_MESSAGE_START\",\"threadId\":\"demo\",\"runId\":\"…\",\"messageId\":\"…\",\"role\":\"assistant\"}\n\ndata:{\"type\":\"TEXT_MESSAGE_CONTENT\",\"threadId\":\"demo\",\"runId\":\"…\",\"messageId\":\"…\",\"delta\":\"It is sunny, 25 C.\"}\n\ndata:{\"type\":\"TEXT_MESSAGE_END\",\"threadId\":\"demo\",\"runId\":\"…\",\"messageId\":\"…\"}\n\ndata:{\"type\":\"CUSTOM\",\"threadId\":\"demo\",\"runId\":\"…\",\"name\":\"token_usage\",\"value\":{\"delta\":{…},\"cumulative\":{\"inputTokens\":83,\"outputTokens\":27,…},\"modelCall\":{…}}}\n\ndata:{\"type\":\"RUN_FINISHED\",\"threadId\":\"demo\",\"runId\":\"…\"}\n```\n\n| Event `type` | Meaning |\n|---|---|\n| `RUN_STARTED` | Always the first event, carries `threadId` and `runId` |\n| `TEXT_MESSAGE_START` \u002F `TEXT_MESSAGE_CONTENT` \u002F `TEXT_MESSAGE_END` | Generated text; concatenate the `delta` of the `CONTENT` events in order to get the reply |\n| `TOOL_CALL_START` \u002F `TOOL_CALL_ARGS` \u002F `TOOL_CALL_END` | A tool the model decided to call; `TOOL_CALL_ARGS` carries fragments of the arguments JSON and only appears when the model streams the arguments in pieces |\n| `TOOL_CALL_RESULT` | The result of a tool, matched to the call by `toolCallId` |\n| `CUSTOM` with `name` = `token_usage` | Token usage after each model call, with `delta` and `cumulative` |\n| `CUSTOM` with `name` = `hint` | A hint the framework adds during reasoning, `value` has `source` and `text` |\n| `RUN_FINISHED` | The normal end |\n| `RUN_ERROR` | Reasoning failed; the HTTP status is still 200 and the stream ends normally instead of dropping the connection. The message is the raw exception message and is not redacted, so do not show it to end users directly |\n\nEvery stream starts with `RUN_STARTED`, even when the agent cannot be created, and ends with either `RUN_FINISHED` or `RUN_ERROR`, never both. When the agent fails while running, the AG-UI adapter maps the exception to `code` (`TIMEOUT_ERROR`, `INTERRUPTED_ERROR`, `INVALID_INPUT_ERROR` or `INTERNAL_ERROR`); failures outside the adapter, such as the agent not being created, are always `INTERNAL_ERROR`. There is no `done` event and the final text is not repeated: the client concatenates `TEXT_MESSAGE_CONTENT`. The temporary agent is closed when the stream completes, fails or the client disconnects. The adapter's `runTimeout` setting is not read by AgentScope 2.0.4, so it does not limit the run time.\n\n> **Breaking change**\n> The earlier private events (`textDelta`, `toolCall`, `toolResult`, `hint`, `done`, `error`) and the `{\"sessionId\", \"message\"}` request body of the streaming endpoint are gone. The streaming endpoint now only accepts `Content-Type: application\u002Fjson`; requests without a `Content-Type`, or with `text\u002Fplain` or `application\u002F*+json`, get 415. `POST \u002Fapi\u002Fchat` now validates `sessionId` with the same rule as `threadId` (non-blank values like `user:42` used to be accepted and now return 400); a blank `sessionId` still starts a new session.\n\n> **Note**\n> Concurrent requests for the same session are not serialized, so avoid sending them at the same time. `HarnessAgent.close()` waits for the framework's global async-write quiescence (up to 5 seconds each for two waits) inside the per-request cleanup, so requests are coupled through it; this has not been load-tested.\n\n## Configuration\n\nConfiguration is split by profile. The `local` profile is active when none is specified; switch with the `SPRING_PROFILES_ACTIVE=prod` environment variable or the `--spring.profiles.active=prod` command-line argument.\n\n- `application.yml`: Shared by all profiles: model, agent, virtual threads, log format, workspace, key prefix and compaction\n- `application-local.yml`: Local development: Volcengine Ark `base-url` and model name live in the file, the API key comes from `ARK_API_KEY` (may be empty), Redis at `redis:\u002F\u002F127.0.0.1:6379` (the one from `docker-compose.yml`), `com.yoke` logs at debug\n- `application-test.yml`: Automated tests: a fake API key, the model is never really called; the Redis address is injected by the tests\n- `application-prod.yml`: Production: the API key and the Redis address (`YOKE_REDIS_URI`) must come from the environment, startup fails without them; graceful shutdown\n\nThe model is created by the official AgentScope starter from `agentscope.*`, and a `HarnessAgent` is built per request by `HarnessAgentFactory` (the official singleton agent is turned off):\n\n| Property | Description |\n|---|---|\n| `agentscope.openai.api-key` | Model API key; `local` reads `ARK_API_KEY`, `prod` reads `OPENAI_API_KEY` |\n| `agentscope.openai.model-name` | Model name |\n| `agentscope.openai.base-url` | Set this to use another OpenAI-compatible service (DashScope, DeepSeek, ...) |\n| `agentscope.agent.sys-prompt` | System prompt |\n| `agentscope.agent.max-iters` | Maximum number of ReAct iterations |\n\nYoke's own settings use the `yoke.*` prefix:\n\n| Property | Description |\n|---|---|\n| `yoke.redis.uri` | Redis connection string. No default in `prod` (`YOKE_REDIS_URI`); the application fails at startup if Redis cannot be reached |\n| `yoke.redis.key-prefix` | Prefix of every Redis key, default `yoke:` |\n| `yoke.compaction.trigger-messages` | Compact the conversation once it reaches this many messages, default 30 |\n| `yoke.compaction.keep-messages` | Messages kept verbatim after a compaction, default 10. Values `\u003C= 0`, or a keep count not smaller than the trigger count, fall back to the defaults |\n| `yoke.workspace` | `HarnessAgent` workspace for local files (offloaded messages, memory), default `~\u002F.yoke\u002Fworkspace`; it stays on the machine and is not shared between replicas |\n\nThe agent is built without file, shell or web tools, and sub-agents are disabled as a whole: reading the 2.0.4 source shows that a sub-agent inherits only the file and shell switches, not the web switch, so leaving sub-agents on would let the model spawn one that can fetch arbitrary URLs. The read-side memory and session tools (`memory_get`, `memory_search`, `session_history`, `session_list`, `session_search`) are denied too: `memory_get` only checks that a path stays inside the workspace root, not inside the current user's directory, and `session_history` puts model-supplied IDs straight into a path, so they would let the model read other users' memory and sessions. What remains is `get_weather`, `memory_save` (only appends to the fixed `MEMORY.md` and `memory\u002F\u003Cdate>.md` in the workspace, without a size limit), `load_skill_through_path` and `wait_async_results`. The tool config is passed in explicitly, so a `tools.json` in the workspace has no effect. A `MiddlewareBase` bean is attached to every new agent; `LoggingMiddleware` logs agent, model and tool timings without tool arguments or outputs. OpenTelemetry tracing is not attached by default: add an OpenTelemetry SDK and exporter and register an `OtelTracingMiddleware` bean when you need it.\n\nTo use another model, replace `agentscope-openai-spring-boot-starter` in `build.gradle` with the matching starter (dashscope, anthropic, gemini or ollama) and change `agentscope.model.provider`.\n\n## Project Structure\n\n```\nsrc\u002Fmain\u002Fjava\u002Fcom\u002Fyoke\u002F\n├── YokeApplication.java        Application entry point\n├── api\u002F                        HTTP contract (ChatApi: paths, validation and docs live here)\n├── codec\u002F                      Conversion between domain types and framework types (MessageCodec, AguiStreamCodec, HintEventConverter)\n├── config\u002F                     Agent, Redis and AG-UI adapter configuration (HarnessAgentFactory, YokeProperties)\n├── controller\u002F                 Contract implementation (ChatController)\n├── middleware\u002F                 Agent middlewares (LoggingMiddleware)\n└── model\u002F                      Request and response objects (ChatRequest, ChatResponse)\nsrc\u002Fmain\u002Fresources\u002F             application.yml and the per-profile configuration\ndocker-compose.yml              Local Redis, also used by the integration tests\ndocs\u002Fbrand\u002F                     Logo\n```\n\n## Learn More\n\n- [AgentScope Java documentation](https:\u002F\u002Fjava.agentscope.io): the full guide to agents, tools, permissions, state stores and more.\n\n## Contributing\n\nIssues and pull requests are welcome. AgentScope message and event types must not leak out of `codec` (and `middleware`, whose hook signatures need them); `ArchitectureTests` enforces this. Before submitting, run `.\u002Fgradlew build` and make sure all tests pass. Code comments are written in Chinese.\n\n## License\n\nYoke is open-sourced software licensed under the [Apache License 2.0](LICENSE).\n\n## Star History\n\n[![Star History Chart](https:\u002F\u002Fapi.star-history.com\u002Fsvg?repos=sinabs\u002Fspring-agent-scope&type=Date)](https:\u002F\u002Fstar-history.com\u002F#sinabs\u002Fspring-agent-scope&Date)\n","spring-agent-scope（Yoke）是一个基于 Spring Boot 4.1 和 AgentScope Java 2.0 构建的 AI 智能体服务框架，专为安全、可扩展的多轮对话场景设计。其核心特性包括：每个 HTTP 请求创建独立生命周期的智能体实例、会话历史持久化至 Redis（按 userId\u002FsessionId 隔离并自动压缩）、支持 SSE 流式响应（遵循 AG-UI 协议）及内置无密钥天气工具。项目采用单体架构，强调工程落地性，解决了官方 starter 中会话混用、权限缺失与部署风险等问题。适用于需用户隔离、会话持久化与生产级可控性的企业级 AI 对话服务开发。",2,"2026-11-24 04:35:14","CREATED_QUERY"]