Skip to content

[Bug]: dp.agentscope_store.item_key varchar(255) too short — every Managed Agent's first Turn fails before model invocation #3461

Closed

Description

@Shaw-shaw

Describe the bug

On AgentScope Service 2.1.0-BETA1 (Docker Compose release), the very first Turn submitted to a freshly created Managed Agent fails immediately, before the model is ever invoked.

Root cause: table dp.agentscope_store defines item_key as character varying(255). The composite keys that HarnessAgent generates for session/agent-instance tracking (combining namespace + agent id + session id, e.g. dpa-namespace:<tenant>:<namespace>-<agentId>-sess_<id>-style strings) regularly exceed 255 characters. The insert is rejected by Postgres with value too long for type character varying(255), which bubbles up as IllegalStateException: JdbcStore putIfVersion (insert) failed, and the Turn is marked failed.

This reproduced consistently for two independently created agents/sessions in the same deployment, so it looks systemic rather than a one-off data issue — it blocks the documented quickstart / "create your first Managed Agent" tutorial from working out of the box on a clean deployment.

This may be related to the agentscope_store sizing issues in #1765 and #3217 (same table, different symptom: here it's an insert-time data-length rejection on Postgres rather than a MySQL index-size/collation problem).

To Reproduce

  1. Follow the Service quickstart (Docker Compose) to deploy 2.1.0-BETA1: init-env.sh, set DASHSCOPE_API_KEY and BUILDER_ALLOW_LOCAL_ENVIRONMENT=true, then docker compose up -d --wait.
  2. Create a Local Environment: POST /api/environments {"name":"test","type":"local","config":{}}.
  3. Create a Managed Agent: POST /api/v1/agents with binding.kind=managed, definition.defaultEnvironmentId set to the environment above, and agent_toolset tools read/write enabled.
  4. Create a Session targeting that agent: POST /api/v1/agent-sessions {"target":{"type":"agent","id":"<AGENT_ID>"}}.
  5. Submit any message as a Turn: POST /api/v1/agent-sessions/{id}/turns.
  6. Poll GET /api/v1/agent-sessions/{id}/turns/{turnId} — status becomes failed within ~1 second, before any model call happens.

Expected behavior

A freshly created Managed Agent's first Turn should execute normally (model call + tool calls) as documented, without any manual schema modification.

Error messages

as-dataplane log:

i.a.h.a.middleware.AgentTraceMiddleware : [<agent-name>] ERROR | IllegalStateException: JdbcStore putIfVersion (insert) failed
i.a.b.web.managed.SessionTurnRunner : Managed session turn failed: sessionId=sess_xxx, error=JdbcStore putIfVersion (insert) failed

Underlying Postgres error (docker compose logs db):

ERROR: value too long for type character varying(255)

followed on the next attempt by:

ERROR: duplicate key value violates unique constraint "agentscope_store_pkey"

Environment

  • AgentScope Service Version: 2.1.0-BETA1 (images as-controlplane, as-gateway, as-dataplane, as-scheduler, all 2.1.0-BETA1)
  • Deployment: official Docker Compose release tarball (agentscope-service-2.1.0-BETA1-compose.tar.gz), Compose v2
  • Database: bundled PostgreSQL 17
  • Java (in as-dataplane): 21.0.12.1 (per startup log Starting DataApp v2.1.0-BETA1 using Java 21.0.12.1)
  • OS: macOS (Darwin), Docker Desktop

Additional context

Local workaround that unblocks the Turn (verified end-to-end — model call plus write_file/read_file tool calls both succeed afterwards):

ALTER TABLE dp.agentscope_store ALTER COLUMN item_key TYPE varchar(512);

This is obviously not a supported fix (manual DDL outside the release's migration path), just confirmation that widening the column resolves it. A proper fix would either widen item_key in the shipped schema, or shorten/hash the generated key so it reliably fits within 255 characters.

Activity

  1. answerallen commented on Oct 11, 2026

    @answerallen

    Independent confirmation on 2.1.0-BETA1 (official compose bundle, PostgreSQL 17) — same root cause, plus two data points that may help #3464.

    The key that overflows the column (277 characters):

    agents/s_<base64>/sessions/s_<base64>/s_<base64>/inbox/commits/<sha256>.json
    

    Full error chain on our side

    [agent] PRE_CALL | 1 input message(s)
    [agent] ERROR  | SessionLogException: Failed to commit session prefix
    Managed session turn failed: sessionId=sess_..., error=Failed to commit session prefix
    

    data-plane debug log:

    IllegalStateException: JdbcStore putIfVersion (insert) failed
    

    PostgreSQL server log (ALTER SYSTEM SET log_statement='mod' to capture the statement):

    ERROR:  value too long for type character varying(255)
    STATEMENT:  INSERT INTO agentscope_store (namespace_path, item_key, value_json, version, updated_at) VALUES ($1,$2,$3,1,$4)
    DETAIL:  Parameters: $2 = 'agents/s_.../inbox/commits/57bc2a86...580e.json'
    

    Workaround verified end-to-end — after this, the same Managed agent runs the turn and answers (reached the model call, POST_CALL | response: ...):

    ALTER TABLE dp.agentscope_store ALTER COLUMN item_key TYPE VARCHAR(1024);

    Two notes for the fix

    1. MysqlDialect.java:74 declares the same VARCHAR(255) (PG PostgresDialect.java:61, H2 H2Dialect.java:47); SqliteDialect.java:48 uses TEXT, so SQLite is unaffected. fix(jdbc): widen agentscope_store.item_key on PostgreSQL and H2 #3464 covers PostgreSQL + H2 — MySQL looks like it needs the same treatment.
    2. Because the short keys (.../session.json, .../head.json) insert fine and only the .../inbox/commits/<sha256>.json key overflows, the table ends up looking "half written" and the failure is easy to misattribute. An ALTER on startup (or a validation error that names the offending column) would save every existing deployment from a manual patch.

    Thanks for #3464 — happy to re-test on this deployment once it lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions