feat(sdk): 普通 prompt 逐条上报用户时区
session/prompt 与 session/query 接受可选 timeZone,TS/Python 客户端透传;省略时逐条采样进程时区,写入 sdk-user 来源的 clientTimeZone。time-context 读取不带 rpcId 的 user 来源时区。补持久化记录、Agent Note、升级指南、README,并刷新 SDK snapshot。
This commit is contained in:
1 parent
71ce86fae6
commit
dca075e2a2
109 files changed
+1428
-421
No files matched your search
@@ -24,7 +24,7 @@ def test_account_provider_signout_snapshot(tmp_path: Path) -> None:
|
||||
model='deepseek-v4-flash',
|
||||
env={'DSH_TELEMETRY_DISABLED': '1', 'DSH_SNAPSHOT': 'replay'},
|
||||
) as harness:
|
||||
result = harness.run('Reply with exactly: SDK snapshot')
|
||||
result = harness.run('Reply with exactly: SDK snapshot', time_zone='UTC')
|
||||
ending = next(event for event in reversed(result.events) if event['type'] == 'turn/end')
|
||||
actual = {
|
||||
'final_response': result.final_response,
|
||||
|
||||
@@ -74,7 +74,7 @@ for line in sys.stdin:
|
||||
elif method == "session/query":
|
||||
serial += 1
|
||||
params = frame["params"]
|
||||
assert set(params) == {"sessionId", "contentBlocks"}
|
||||
assert set(params) - {"timeZone"} == {"sessionId", "contentBlocks"}
|
||||
text = input_text(frame)
|
||||
if text == "/plan hold":
|
||||
identity = "plan-" + str(serial)
|
||||
@@ -452,3 +452,30 @@ def test_low_level_prompt_keeps_slash_text_as_an_ordinary_prompt(sdk: DeepSeekHa
|
||||
sent = [json.loads(line) for line in (tmp_path / "requests.jsonl").read_text(encoding="utf-8").splitlines()]
|
||||
assert sent[-1]["method"] == "session/prompt"
|
||||
assert sent[-1]["params"] == {"sessionId": "main", "contentBlocks": blocks}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("entry", ["session", "harness"])
|
||||
def test_run_sends_its_prompt_time_zone_as_the_time_zone_wire_field(
|
||||
sdk: DeepSeekHarness, tmp_path: Path, entry: str,
|
||||
) -> None:
|
||||
result = (sdk.run("ordinary", session_id="main", time_zone="Asia/Shanghai")
|
||||
if entry == "harness" else sdk.start_session("main").run("ordinary", time_zone="Asia/Shanghai"))
|
||||
assert isinstance(result, RunResult)
|
||||
sdk.start_session("main").run("ordinary")
|
||||
sent = [json.loads(line) for line in (tmp_path / "requests.jsonl").read_text(encoding="utf-8").splitlines()]
|
||||
assert [frame["params"] for frame in sent if frame["method"] == "session/query"] == [
|
||||
{"sessionId": "main", "contentBlocks": [{"type": "text", "text": "ordinary"}], "timeZone": "Asia/Shanghai"},
|
||||
{"sessionId": "main", "contentBlocks": [{"type": "text", "text": "ordinary"}]},
|
||||
]
|
||||
assert_released(sdk)
|
||||
|
||||
|
||||
def test_low_level_prompt_sends_its_time_zone_as_the_time_zone_wire_field(sdk: DeepSeekHarness, tmp_path: Path) -> None:
|
||||
blocks = [{"type": "text", "text": "when is noon?"}]
|
||||
sdk.client.session_prompt("main", blocks, time_zone="UTC")
|
||||
sdk.client.session_prompt("main", blocks)
|
||||
sent = [json.loads(line) for line in (tmp_path / "requests.jsonl").read_text(encoding="utf-8").splitlines()]
|
||||
assert [frame["params"] for frame in sent if frame["method"] == "session/prompt"] == [
|
||||
{"sessionId": "main", "contentBlocks": blocks, "timeZone": "UTC"},
|
||||
{"sessionId": "main", "contentBlocks": blocks},
|
||||
]
|
||||
Reference in new issue
Block a user