Skip to content

Capability seeds never re-sync functionDefinition on update → schema changes to existing tools never reach the DB #545

Description

@simonholmes

Every built-in capability seed's AiCapability upsert uses:

update: { isSystem: true },
create: {, functionDefinition,},

The update branch omits functionDefinition, so once a capability row exists, any later change to its function schema never propagates on re-seed — the DB (and therefore the MCP tool list / what the LLM sees) keeps advertising the original schema forever.

Affects the seeds that upsert AiCapability: call_external_api, run_workflow, upload_to_storage, send_message_to_channel, model_auditor, pattern_advisor.

Why it's easy to miss

The parity tests pin class ↔ seed constant, not seed constant ↔ DB row. Everything is green while the live tool is stale. We hit this in a downstream fork: added a parameter to a capability, all tests passed, but the MCP schema on both dev and prod never showed the new field until we fixed the seed's update branch.

Suggested fix

Re-sync functionDefinition on the update branch for isSystem capabilities (it's code-owned — it must track the class), while leaving admin-editable fields (name / description / isActive) untouched:

update: { isSystem: true, functionDefinition: <thatDef> },

A regression test that runs the seed unit against a mock prisma and asserts the update branch carries functionDefinition prevents recurrence.

The same "update branch drops code-owned fields" shape may affect other seeded system config (e.g. built-in agents' prompts) — worth an audit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingupstream-gapGap surfaced building a fork; tracked for upstream fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions