[Bug]:PostgresAgentStateStore存储记忆有问题
private String slotSessionId(SandboxIsolationKey key) { IsolationScope scope = key.getScope(); return switch (scope) { case SESSION -> "sandbox/session/" + key.getValue(); case USER -> "sandbox/user/" + agentId + "/" + key.getValue(); case AGENT -> "sandbox/agent/" + agentId; case GLOBAL -> "sandbox/global"; }; } 和 protected void validateSessionId(String sessionId) { if (sessionId == null || sessionId.trim().isEmpty()) { throw new IllegalArgumentException("AgentStateStore ID cannot be null or empty"); } if (sessionId.contains("/") || sessionId.contains("\")) { throw new IllegalArgumentException("AgentStateStore ID cannot contain path separators"); } if (sessionId.length() > 255) { throw new IllegalArgumentException("AgentStateStore ID cannot exceed 255 characters"); } } 存在冲突
这个我来修一下 👍
根因:SessionSandboxStateStore.slotSessionId() 用 / 拼 slot id(如 sandbox/session/<id>),而 SQL store 的 validateSessionId 会拒绝 / 和 \,所以带隔离作用域时 sandbox 状态在 Postgres/MySQL 上持久化会必抛 IllegalArgumentException(不止 Postgres,MySQL 也一样)。
打算对齐 MysqlAgentStateStore#slotId 已经在用的 : 分隔符约定,把 / 换成 :,一处修好所有 store,并补一个覆盖四种作用域的回归测试。PR 马上提。
This is a valid bug. There's a conflict between slotSessionId() and validateSessionId() in PostgresAgentStateStore:
slotSessionId()generates paths likesandbox/session/{value}andsandbox/user/{agentId}/{value}— these contain/characters.validateSessionId()explicitly rejects any sessionId containing/or\\.
This means any session ID generated by slotSessionId() would fail validation, making the store unusable for SESSION and USER isolation scopes.
Suggested fix: Either:
- Change
validateSessionId()to allow/in paths (since they're internal storage keys, not user-facing IDs), or - Use a different separator (e.g.,
:or__) inslotSessionId()that doesn't conflict with the validation rules.