Repository navigation
fix(jdbc): widen agentscope_store.item_key on PostgreSQL and H2 - #3464
Conversation
The keys written through JdbcStore are workspace file paths and session journal paths -- agents/<name>/users/<user>/sessions/<id>.log.jsonl and the like -- whose ids regularly push them past 255 characters. The store DDL declared item_key as VARCHAR(255) on every vendor, so the very first write of a fresh session was rejected with "value too long for type character varying(255)", surfacing as "JdbcStore putIfVersion (insert) failed" before the model was ever called. On AgentScope Service 2.1.0-BETA1 this fails the first Turn of every freshly created Managed Agent on a clean deployment. Widen the column to VARCHAR(2048), matching namespace_path, on PostgreSQL and H2. SQLite already uses TEXT. MySQL deliberately keeps VARCHAR(255): next to namespace_path VARCHAR(512) its utf8mb4 composite primary key already sits at InnoDB's 3072-byte limit, as the dialect's own comment records. Startup validation compares column names only, so a PostgreSQL table created before this change keeps its 255-character column silently. Document the one-off ALTER for existing deployments next to the component. Fixes agentscope-ai#3461
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Independent verification on a clean deployment — the patch is correct, and I suggest merging it. What I ran
Results
The failing key confirms the shape described in the PR body: 256 characters is 1 over the old limit, and it was written by the very first Turn of a session created seconds earlier — so this hits the documented quickstart on a clean install, not only long-lived deployments. Two notes for the reviewer
|
|
Independent reproduction on The overflow is exactly one character The failing key is 256 characters against
So the failure boundary is
How it was measured PostgreSQL log with Falsification, not just correlation
Supporting the PostgreSQL/H2-only scope Agreed on excluding MySQL: Two things worth adding to this PR
Reproduced independently of #3461 — +1 for merging. |
…y column The widening covered the inbox/commits/ key that failed on the quickstart, but the same session path also writes writer-seals/ at the root and below inbox/. The inbox-level one is 261 characters, six over the old limit and reachable from SessionNativeLogService.sealWriter, and nothing pinned either of them. The new test builds the keys from the real SessionKey, writes all three shapes through JdbcStore on H2, and asserts that the measured failure case stays over the old 255-character width while fitting the widened one, together with the maximum-length id case. Narrowing the column back to 255 makes it fail.
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
|
Pushed a commit that covers the first suggestion — the other key shapes are now bounded too.
It also asserts that the measured failure case stays over the old 255-character width and fits the widened one, and that ids at their maximum length still fit. Narrowing the column back to 255 makes it fail, so the guard is not vacuous. Good catch on the On the second point, the migration note is in Thanks for measuring the boundary at both ends — "under 255 by zero" and "over by six" is a much sharper statement than the single failing key, and it is what the test is built around. |
|
@jujn — #3464 is 29 days old and has two independent reproductions that both recommend merge, which is unusual enough that I would rather you see them than take my word:
One thing I want your call on rather than mine: @zachMelody's #3583 answers the same issue #3461 by projecting turns into the session log instead of widening the column. If that is the direction you prefer, I would rather withdraw #3464 than have two conflicting answers land. If widening is useful regardless — it also protects databases that already hold short keys from the next long one — it is one line per dialect plus a migration note in the docs. #3559 is the same class of defect in a different table, if you would rather look at them together. |
|
cc @xzxiaoshan |
Backport the verified fix to the 2.0.x implementation and retain its existing public contracts where the upstream kernel differs. (cherry picked from commit 7d84cff) Constraint: No AgentScope Service or SDK migration Confidence: high Not-tested: Whole-repository verification pending after lane integration
…tscope-ai#3464) New PostgreSQL and H2 tables created by the unified io.agentscope.extensions.jdbc.store.JdbcStore now use item_key VARCHAR(2048), matching namespace_path. Workspace and session journal paths regularly exceed 255 characters, which made the first write of a fresh managed session fail with "value too long for type character varying(255)". MySQL keeps 255 characters so the composite primary key stays within the InnoDB utf8mb4 index limit; the legacy io.agentscope.extensions.mysql.store.JdbcStore is unchanged. Existing tables are never altered automatically; the migration steps are documented in the EN and ZH session storage pages. (cherry picked from commit 440ef85)
Symptom
On AgentScope Service
2.1.0-BETA1(Docker Compose, PostgreSQL) the firstTurnof every freshly created Managed Agent fails before the model is invoked:Reported in #3461, reproduced there on two independently created agents, so it is systemic — it blocks the documented quickstart on a clean deployment.
Root cause
agentscope_store.item_keyisVARCHAR(255)in every dialect's DDL (PostgresDialect.java:61,H2Dialect.java:47,MysqlDialect.java:79; SQLite usesTEXT). But the keys written throughJdbcStoreare not short ids — they are workspace file paths (RemoteFilesystem.write(…, filePath, …)→store.putIfVersion(ns, filePath, …)) and session journal paths (StoreSessionStorage.compareAndSet(path, …)), i.e.agents/<name>/users/<user>/sessions/<id>.log.jsonlwith generated ids in them. Those regularly exceed 255 characters.namespace_pathnext to it is alreadyVARCHAR(2048)on PostgreSQL/H2, so the asymmetry was never a deliberate size budget on those vendors.Fix
Widen
item_keytoVARCHAR(2048)— matchingnamespace_path— on PostgreSQL and H2 only.MySQL deliberately stays at
VARCHAR(255). Its dialect records why:Widening it there would break table creation (#1765 was that failure). MySQL is not the Service dataplane's database (
application.ymlis PostgreSQL-only), so the reported deployment is covered without touching the MySQL budget. The existingDialectSqlTestsassertion on the MySQL DDL stays green untouched.Existing deployments
Startup validation (
TableSchemaValidator) compares column names only, never types or lengths, and the framework never alters an existing table. So a PostgreSQL table created before this change keeps its 255-character column silently. The docs page for the module already has a "the framework never alters existing tables — run this once by hand" convention; I added the matching note under §2 JdbcStore in bothenandzh:(For the Service compose stack that is
dp.agentscope_store;currentSchema=dpon the JDBC URL resolves the unqualified name.)Tests
New
JdbcStoreLongKeyH2Test(H2 enforcesVARCHARlength, so no Docker needed): a 300-character key throughputIfVersionand a 600-character key throughput, both built as a realistic session journal path and read back by key.Red — on current
mainboth fail with exactly the reported shape:Green — with the fix, the new class and every non-Docker dialect / store / state / skill test in the module pass: 177 tests across 16 classes, 0 failures.
spotless:applyapplied.No database migration code and no configuration change; the manual
ALTERfor pre-existing PostgreSQL tables is documented rather than automated, consistent with the module's stated policy.Fixes #3461