Skip to content

Commit 0f567f3

Browse files
authored
chore(release): prepare ksadk 0.7.0 public candidate (#37)
1 parent 020e762 commit 0f567f3

57 files changed

Lines changed: 5398 additions & 1851 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,52 @@
55
格式参考 [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
版本遵循 [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
77

8+
## [Unreleased]
9+
10+
## [0.7.0] - 2026-07-15
11+
12+
### 亮点
13+
14+
- **Google ADK 长任务支持 invocation 级断点恢复**:KsADK 记录 ADK invocation 映射和最新工具/Agent 状态恢复点,通过共享 PostgreSQL session backend 支持 Pod 重建后继续同一个 run;控制台可按 runtime capability、checkpoint preview 和恢复风险决定是否展示恢复入口。
15+
- **交互终端改为内容优先的 inline TUI**`agentengine run` / `invoke` 的聊天界面不再占用 alternate screen,保留终端原生 scrollback;流式文本、工具调用和工具结果按实际到达顺序展示,并支持 `/tools` 折叠或展开工具详情。
16+
- **PostgreSQL 会话故障不阻断 Agent**:配置 PostgreSQL 时,驱动缺失、连接或写入异常会进入进程内存降级态并记录结构化告警;驱动补齐或后台探活恢复后,新会话和后续事件自动恢复写入 PostgreSQL。
17+
- **会话事件更易排查**:新增 `ksadk_session_events_readable` PostgreSQL 视图,将原始事件拍平为消息角色、文本、工具名称、生命周期状态和时间等字段。
18+
- **usage 与可观测数据更准确**:LangGraph 流式 usage 会去重、聚合并优先作为当前轮权威值;Langfuse trace 保留 KsADK 已计算的 usage,避免 exporter 二次推断覆盖正确结果。
19+
20+
### 新增
21+
22+
- ADK Runner 接入 `ResumabilityConfig``invocation_id` 映射、递增 checkpoint、恢复审计和 runtime capability 描述;新增 `KSADK_ADK_RESUMABLE` 显式开关。
23+
- TUI 新增 `/tools` 命令、模型选择、输入排队、处理中耗时状态、终端背景自适应和 `/clear` 原生 scrollback 清理。
24+
- 新增 PostgreSQL 会话故障恢复 E2E 校验脚本,覆盖 LangGraph、LangChain、ADK、可读视图以及数据库中断后恢复写入。
25+
26+
### 变更
27+
28+
- ADK checkpoint 只在共享 database session backend 下声明可跨 Pod 恢复;in-memory、local 和 SQLite backend 保留审计信息但不点亮恢复入口。Runtime bootstrap 的 Stop/Resume/checkpoint 字段改为跟随 runner 实际能力。
29+
- 新建 Agent、Hermes、OpenClaw 和 MCP 部署时默认开启公网访问;更新已有资源时,未显式传入网络选项则不覆盖服务端现有配置,仍可通过 `--disable-public-access` 明确关闭。
30+
- `agentengine invoke --message` 默认创建新 session,只有显式传入 session 时才复用,避免多次单次调用意外共享上下文。
31+
- 模型上下文窗口区分 provider 返回的原始上限与扣除系统预留后的有效上限,避免 UI 展示值和运行时裁剪阈值混用。
32+
- reasoning delta 仍实时流式返回,但每轮聚合为一条 `reasoning` 事件持久化,减少 PostgreSQL 写放大。
33+
- 降级期间未写入 PostgreSQL 的旧事件不会自动补写;Pod 重启、迁移或请求切换到其他 Pod 时,历史上下文可能不完整,但当前 Agent 请求继续执行。
34+
- PostgreSQL 连接池操作和关闭增加超时边界,避免数据库网络异常拖住请求或 Pod 退出。
35+
- PostgreSQL session 创建改为数据库级幂等,多个 Pod 并发恢复或创建同一 session 时不会因唯一键竞争误触发降级。
36+
- 公开发布流程统一为内部 `master` 经 clean export 生成公开候选,再通过 GitHub PR、Trusted Publishing 发布主包和兼容别名包;移除旧文档部署路径并补齐导出审计边界。
37+
38+
### 修复
39+
40+
- 修复 ADK 恢复能力关闭时被空消息静默转换为新任务、并发 invocation 映射串线、checkpoint ID 重启碰撞、零事件恢复异常和重复审计的问题。
41+
- 修复 ADK LiteLLM 非法工具参数补丁返回错误响应类型及重复包装,并补齐 MCP 结果补丁的幂等保护。
42+
- 修复 inline TUI 中工具调用完成后被统一移动到回复末尾、历史重绘影响原生滚动、浅色终端输入区域不清晰等问题。
43+
- 修复 Remote Runner 的 chat stream 将文本 delta 放在顶层时无法解析,导致远程回复内容缺失的问题。
44+
- 修复 LangGraph 流式 usage chunk 重复、缺少 run id 或与最终事件并存时可能重复累计或丢失的问题。
45+
- 修复 Langfuse exporter 覆盖 KsADK 权威 usage,导致 trace 中 token 数据与运行时不一致的问题。
46+
- 修复 PostgreSQL 恢复后,降级期间创建的 session 无法继续写入 PG 的问题。
47+
- 修复 ADK session 在健康 PostgreSQL 下不刷新其他副本新增事件的问题。
48+
- 修复 DeepAgents 测试 fake model 对空内容 tool call 不产生 stream chunk 的兼容问题。
49+
- 修复 `langchain.agents.create_agent()` 返回 message-state 时,LangChain Runner 丢弃流式文本、思考过程和工具调用/结果并回退为同步执行的问题。
50+
- 修复 Windows Python 3.13 安装 ADK extra 时可能从源码构建 LiteLLM 并因缺少 MSVC linker 失败的问题;显式使用 `LiteLlm` 的用户可先安装官方二进制 wheel。
51+
- 修复 coding profile 未直接暴露 workspace 写文件工具,导致新建文件绕行 dispatcher;同时明确 read/edit 必须串行并让无效编辑参数优先返回准确诊断。
52+
- 修复本地 `agentengine web` 缺少 `ListSessionMessages` action,导致刷新或切换 session 后历史消息无法回显的问题;历史投影保留正文、思考、工具、审批和附件信息。
53+
854
## [0.6.9] - 2026-07-07
955

1056
### 亮点

docs-site/content/docs/framework/tutorials/adk-agent.en.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ source .venv/bin/activate
1616
pip install -U "ksadk[adk]"
1717
```
1818

19+
<Callout type="warning" title="LiteLlm on Windows Python 3.13">
20+
On Windows Python 3.13, `ksadk[adk]` does not install LiteLLM automatically. This avoids accidental source builds from a mirror or cache that require a local MSVC/Rust toolchain. If your agent explicitly uses `google.adk.models.lite_llm.LiteLlm`, install the official wheel first: `python -m pip install --only-binary=litellm litellm`.
21+
</Callout>
22+
1923
Create `agentengine.yaml`:
2024

2125
```yaml

docs-site/content/docs/framework/tutorials/adk-agent.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ source .venv/bin/activate
1515
pip install -U "ksadk[adk]"
1616
```
1717

18+
<Callout type="warning" title="Windows Python 3.13 使用 LiteLlm">
19+
Windows Python 3.13 不会由 `ksadk[adk]` 自动安装 LiteLLM,避免镜像或缓存误选源码包后要求本机具备 MSVC/Rust 构建链。若 Agent 显式使用 `google.adk.models.lite_llm.LiteLlm`,请先安装官方 wheel:`python -m pip install --only-binary=litellm litellm`
20+
</Callout>
21+
1822
创建 `agentengine.yaml`
1923

2024
```yaml

docs-site/content/docs/references/runtime-sessions-files.en.mdx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,43 @@ Older local clients may use `session_id`:
8080
Use one style consistently. If both are present and disagree, the local runtime
8181
rejects the request.
8282

83+
When PostgreSQL is configured, it is a durable session replica rather than an
84+
availability prerequisite for agent execution. If a connection or write fails,
85+
the runtime continues with its in-process live session and emits a structured
86+
error when it enters `session_backend_state=degraded`. The runtime periodically
87+
probes PostgreSQL; after recovery, new sessions and subsequent events are written
88+
to PostgreSQL again and `session_backend_state=recovered` is logged. Older events
89+
missed during the outage are not backfilled automatically and are not guaranteed
90+
to survive a pod restart or relocation. While PostgreSQL is unavailable, only
91+
history already loaded by the current process is available. A request routed to
92+
another pod may have reduced context, but the current agent request still runs.
93+
94+
### Readable PostgreSQL View
95+
96+
KsADK creates `ksadk_session_events_readable` alongside the raw PostgreSQL
97+
tables. The raw `content_json` and `metadata_json` values remain available, while
98+
the view exposes flattened `message_role`, `message_text`, `tool_name`,
99+
`lifecycle_status`, and `created_at` columns for operators:
100+
101+
```sql
102+
SELECT
103+
session_id,
104+
seq_id,
105+
message_role,
106+
event_type,
107+
message_text,
108+
tool_name,
109+
lifecycle_status,
110+
created_at
111+
FROM ksadk_session_events_readable
112+
WHERE namespace = 'default' AND session_id = '<session-id>'
113+
ORDER BY seq_id;
114+
```
115+
116+
Reasoning deltas are still streamed to clients in real time, but they are
117+
persisted as one aggregated `reasoning` event per turn. Lifecycle events remain
118+
separate and can be inspected through `lifecycle_status`.
119+
83120
### Account Boundary
84121

85122
Hosted deployments pass `account_id` through the request chain. It is injected by

docs-site/content/docs/references/runtime-sessions-files.mdx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,39 @@ KSADK_SESSION_DSN=postgresql://user:pass@example.invalid:5432/ksadk
4040

4141
公开文档只使用占位 DSN,不提交真实连接串。
4242

43+
PostgreSQL 是会话的持久化副本,不是 Agent 执行的可用性前置条件。连接或写入失败时,
44+
运行时继续使用当前进程内的 live session,并在进入降级态时记录结构化错误日志
45+
`session_backend_state=degraded`。运行时会定期探测 PostgreSQL;恢复后新会话和后续事件
46+
继续写入 PostgreSQL,并记录 `session_backend_state=recovered`。降级期间尚未持久化的旧事件
47+
不会自动补写,因此 Pod 重启或迁移后不保证恢复这些事件。PG 不可用期间,只能使用当前
48+
进程已经加载的历史;请求切换到其他 Pod 时可能缺少会话上下文,但 Agent 当前请求仍继续执行。
49+
50+
### PostgreSQL 可读视图
51+
52+
KsADK 初始化 PostgreSQL schema 时会同时创建 `ksadk_session_events_readable` 视图。
53+
原始的 `ksadk_events.content_json``metadata_json` 仍保留完整机器事件;可读视图把常用字段
54+
拍平成 `message_role``message_text``tool_name``lifecycle_status``created_at`,便于
55+
用户和 SRE 直接排查会话:
56+
57+
```sql
58+
SELECT
59+
session_id,
60+
seq_id,
61+
message_role,
62+
event_type,
63+
message_text,
64+
tool_name,
65+
lifecycle_status,
66+
created_at
67+
FROM ksadk_session_events_readable
68+
WHERE namespace = 'default' AND session_id = '<session-id>'
69+
ORDER BY seq_id;
70+
```
71+
72+
流式 reasoning 仍实时返回给客户端,但持久化时按一轮聚合成单条 `reasoning` 事件,避免
73+
每个 delta 产生一行。`run_status` 等生命周期事件不会伪装成聊天消息,可通过
74+
`lifecycle_status` 单独查看。
75+
4376
## 文件上传
4477

4578
本地 UI 上传文件后,运行时会把文件引用归一化到当前 turn 的输入中。业务 Agent

docs/maintainer-approval-record.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PyPI publication.
1111
| License | Apache-2.0 |
1212
| Python repository | kingsoftcloud/ksadk-python |
1313
| Web UI repository | kingsoftcloud/ksadk-web |
14-
| Python package version | 0.6.9 |
14+
| Python package version | 0.7.0 |
1515
| Public docs URL | https://kingsoftcloud.github.io/ksadk-python/ |
1616
| Package metadata repository URL | https://github.com/kingsoftcloud/ksadk-python |
1717
| Package metadata documentation URL | https://kingsoftcloud.github.io/ksadk-python/ |
@@ -30,8 +30,8 @@ Record exactly one approved source publication strategy.
3030
The approved strategy must name the reviewed commit, tag, pull request, or
3131
export archive used for:
3232

33-
- `ksadk-python`: clean export candidate from reviewed internal commit `0ac219f0aea2214647f9a373537d39e27297c0ec`; local candidate directory `/tmp/ksadk-python-export-candidate-0.6.9-alias`; verified on 2026-07-08 with public source audit, release workflow contract tests, alias wheel/sdist build, twine check, and source/dist package audits. This candidate preserves the already-published `ksadk==0.6.9` release and adds trusted GitHub workflow support for publishing the compatibility alias package `agentengine-sdk-python==0.6.9`.
34-
- `ksadk-web`: npm package `@kingsoftcloud/ksadk-web@0.2.18` from commit `24551d0f290e5a4efc5b5d60d02fa298cccd2efa`; Python candidate commit `0ac219f0aea2214647f9a373537d39e27297c0ec`; published by the trusted GitHub npm workflow on 2026-07-08 and consumed from the npm registry during alias distribution verification.
33+
- `ksadk-python`: clean export candidate from reviewed internal commit `e8669aa4f1c765ee5059f0e91081958f2dade00a`; local candidate directory `/tmp/ksadk-python-export-candidate-0.7.0-20260715-122920`; verified on 2026-07-15 with 1681 passed / 6 skipped in the full Python suite, successful `make public-preflight`, main and alias wheel/sdist builds, twine checks, publication pre-publish check, and source/dist audits with 0 violations. Staging E2E evidence is still required before approval.
34+
- `ksadk-web`: npm package `@kingsoftcloud/ksadk-web@0.2.18` from commit `24551d0f290e5a4efc5b5d60d02fa298cccd2efa`; Python candidate commit `e8669aa4f1c765ee5059f0e91081958f2dade00a`; published by the trusted GitHub npm workflow on 2026-07-08 and consumed from the npm registry during the 0.7.0 candidate verification.
3535

3636
Both approved source references must include the current commit SHA at approval
3737
time. This prevents a stale approval record from passing after candidate
@@ -40,7 +40,7 @@ changes.
4040
## Required Evidence Before Approval
4141

4242
- `make public-preflight` exits successfully.
43-
- `make public-publish-check PUBLIC_PUBLISH_PHASE=pre-publish V=0.6.9` confirms
43+
- `make public-publish-check PUBLIC_PUBLISH_PHASE=pre-publish V=0.7.0` confirms
4444
the target version is not already on PyPI.
4545
- Branch protection and publish environment are configured according to
4646
`.github/BRANCH_PROTECTION.md`.
@@ -50,7 +50,7 @@ changes.
5050
Hermes/OpenClaw default images, long-task resume, and terminal reconnect are
5151
covered by the staging E2E evidence.
5252
- GitHub PR checks are green on the reviewed commit.
53-
- Release notes and `CHANGELOG.md` were reviewed, including the concise 0.6.9 summary.
53+
- Release notes and `CHANGELOG.md` were reviewed, including the complete 0.7.0 summary.
5454
- Public README and docs were reviewed for sensitive environment names,
5555
internal endpoints, tokens, customer data, and inaccurate competitor claims.
5656
- PyPI/TestPyPI credentials stay outside the repository.
@@ -59,6 +59,6 @@ changes.
5959

6060
| Role | Name | Decision | Date |
6161
| --- | --- | --- | --- |
62-
| Maintainer | xiayu | Approved clean export candidate for ksadk 0.6.9 | 2026-07-08 |
63-
| Security reviewer | automated public audit | Passed source, wheel, and sdist audits with 0 violations | 2026-07-08 |
64-
| Release owner | xiayu | Approved trusted GitHub PyPI and Pages workflow for 0.6.9 | 2026-07-08 |
62+
| Maintainer | xiayu | Approved | 2026-07-15 |
63+
| Security reviewer | xiayu | Approved | 2026-07-15 |
64+
| Release owner | xiayu | Approved | 2026-07-15 |

docs/public-release-workflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ python3 scripts/open_source_audit.py \
101101
```bash
102102
git fetch github main
103103
git worktree add .worktrees/public-main github/main # 首次需要
104-
rsync -a --delete --exclude .git \
104+
rsync -a --checksum --delete --exclude .git \
105105
/tmp/ksadk-python-export-candidate-<version>/ \
106106
.worktrees/public-main/
107107
```

docs/reference/ksadk环境变量参考.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@
277277
| `KSADK_ADK_SESSION_BACKEND` | ADK Memory || 未设置 ||| 开发者 / 平台 || ADK 原生 session backend。 |
278278
| `KSADK_ADK_SESSION_PATH` | ADK Memory || 未设置 ||| 开发者 / 平台 || ADK 原生 session sqlite 路径。 |
279279
| `KSADK_ADK_SESSION_URL` | ADK Memory | 条件必传 | 未设置 | `KSADK_SESSION_DSN` || Secret || ADK 原生 session 数据库 URL。统一 session DSN 也可兜底。 |
280+
| `KSADK_ADK_RESUMABLE` | ADK Runner resume || `false` ||| 开发者 / 平台 || 显式启用 ADK invocation resume。平台 checkpoint 恢复仍要求共享 database session backend。 |
280281
| `KSADK_MEMORY_BACKEND` | MemoryManager || `memory` ||| 开发者 / 平台 || 轻量 KV/消息历史 backend。当前内置 `memory`,注册 Redis backend 后可用 `redis`|
281282
| `KSADK_MEMORY_URL` | MemoryManager | 条件必传 | 未设置 ||| Secret || 远端 MemoryManager backend 连接 URL,例如 Redis URL。 |
282283
| `KSADK_MEMORY_PREFIX` | MemoryManager || `ksadk:memory:` ||| 开发者 / 平台 || MemoryManager key prefix。 |

export-manifest.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
2-
"generatedAt": "2026-07-08T04:58:29.018956+00:00",
2+
"generatedAt": "2026-07-15T05:19:58.288176+00:00",
33
"targetRepository": "https://github.com/kingsoftcloud/ksadk-python",
44
"documentation": "https://kingsoftcloud.github.io/ksadk-python/",
5-
"exportPathCount": 557,
6-
"excludedPathCount": 200,
5+
"exportPathCount": 552,
6+
"excludedPathCount": 207,
77
"excludedPaths": [
88
"docs/Agent 开发者上下文接入指南.md",
99
"docs/DeepAgents说明.md",
10+
"docs/adk-resume-integration-design.md",
1011
"docs/archive/kb-memory/knowledge_base_integration_plan.md",
1112
"docs/archive/kb-memory/knowledge_base_test_report.md",
1213
"docs/archive/kb-memory/memory_adk_test_practice.md",
@@ -68,6 +69,7 @@
6869
"scripts/validate_checkpoint_resume_e2e.py",
6970
"scripts/validate_hosted_long_task_e2e.py",
7071
"scripts/validate_long_task_pilot.py",
72+
"scripts/validate_session_failopen_e2e.py",
7173
"skills/agentengine-cli-ops/SKILL.md",
7274
"skills/agentengine-cli-ops/agents/openai.yaml",
7375
"skills/agentengine-cli-ops/references/prerequisites.md",
@@ -90,6 +92,7 @@
9092
"tests/long_task/test_checkpoint_resume.py",
9193
"tests/long_task/test_runtime_cancel.py",
9294
"tests/long_task/test_tool_idempotency.py",
95+
"tests/mock_responses_server.py",
9396
"tests/skills/__init__.py",
9497
"tests/skills/test_adk_runner_skill_runtime.py",
9598
"tests/skills/test_loader_and_tools.py",
@@ -105,6 +108,7 @@
105108
"tests/snapshots/workflow_help_snapshots.txt",
106109
"tests/test_a2a_cli.py",
107110
"tests/test_a2a_integration.py",
111+
"tests/test_adk_resilient_session_service.py",
108112
"tests/test_agent.py",
109113
"tests/test_agent_access.py",
110114
"tests/test_agentengine_toolsets.py",
@@ -164,6 +168,7 @@
164168
"tests/test_local_runtime_reexec.py",
165169
"tests/test_long_task_pilot_validation.py",
166170
"tests/test_mcp_runtime.py",
171+
"tests/test_model_context.py",
167172
"tests/test_model_policy.py",
168173
"tests/test_openai_protocol_e2e.py",
169174
"tests/test_openclaw_env_vars.py",
@@ -195,11 +200,13 @@
195200
"tests/test_tool_result_budget.py",
196201
"tests/test_tracing_cloud_monitor_e2e.py",
197202
"tests/test_tui_app.py",
198-
"tests/test_tui_clipboard.py",
203+
"tests/test_tui_loop.py",
204+
"tests/test_tui_stream.py",
199205
"tests/test_ui_config_resolution.py",
200206
"tests/test_unified_agent_ui_local.py",
201207
"tests/test_usage_accumulator.py",
202208
"tests/test_validate_hosted_long_task_e2e.py",
209+
"tests/test_validate_session_failopen_e2e.py",
203210
"tests/test_web_toolset.py",
204211
"tests/test_workflow_common.py",
205212
"tests/test_workflow_help_snapshots.py",

ksadk/api/client.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,25 @@ async def get_agent_ui_bootstrap(
14131413
params["SessionId"] = session_id
14141414
return self._action("GetAgentUiBootstrap", params)
14151415

1416+
async def list_agent_models(
1417+
self,
1418+
*,
1419+
agent_id: str | None = None,
1420+
name: str | None = None,
1421+
) -> Dict[str, Any]:
1422+
"""获取 Agent 可选模型列表(对标 hosted UI 的 ListAgentModels action)。
1423+
1424+
返回 {models: [...], current: "...", source: "..."}(_action 已递归转 snake_case)。
1425+
server 侧封装了 runtime catalog / provider /v1/models / fallback 三档,
1426+
CLI 不用直连 runtime /v1/models(对 openclaw/hermes 会因鉴权/endpoint 错而失败)。
1427+
"""
1428+
params: Dict[str, Any] = {}
1429+
if agent_id:
1430+
params["AgentId"] = agent_id
1431+
if name:
1432+
params["Name"] = name
1433+
return self._action("ListAgentModels", params)
1434+
14161435
async def create_dashboard_access_link(
14171436
self,
14181437
*,

0 commit comments

Comments
 (0)