Skip to content

[ENG-1706] Show an unnamed connection's engine as its label in the datasource context - #563

Merged
tino097 merged 6 commits into
stagingfrom
tino097/eng-1706-a-handcrafted-connector-form-discards-the-engine-it-declared
Oct 15, 2026
Merged

tino097 merged 6 commits into
stagingfrom
tino097/eng-1706-a-handcrafted-connector-form-discards-the-engine-it-declared

Conversation

@tino097

@tino097 tino097 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

https://linear.app/mindsdb/issue/ENG-1706/a-handcrafted-connector-form-discards-the-engine-it-declared

What changed

  • Show an unnamed connection's engine as its label in the datasource context, not "(none)". build_datasource_context renders Label: {user_label or engine}; the stored _user_label and the catalog's label field are unchanged.
  • Fall back to the slug when a connection has no engine either, and keep the engine fallback out of the catalog label. A malformed record no longer renders an empty Label:, and a test pins CatalogConnection.label staying "" for an unnamed connection.

Why this matters

mindsdb/cowork-server#646 stops writing the engine id as a default _user_label, so a connection nobody named reached the prompt as Label: (none) instead of Label: postgres. On the scm-trap-out-of-horizon eval that dropped declining-without-a-figure from 8/8 to 1/8 (judge 0.86 → 0.54). With this change and no stored label, it is 5/5 (judge 0.88).

Notes for the reviewer

  • Prompt text only. For unnamed connections the model again sees the engine as the label; _user_label keeps meaning "someone named this". One difference from the old stored default: two unnamed connections of one engine both read Label: postgres (the old default numbered the second postgres 2); their slugs still tell them apart.

Ships with

Checks

Check Observed result
uv run pytest 4962 passed, 91 skipped
Regression test test_no_label_falls_back_to_the_engine fails on the old line and passes with the fix; the no-engine test fails without the slug fallback
Eval (scm-trap-out-of-horizon, T4, 5 repeats, unlabelled connection) 5/5, judge 0.88 (run r-2026-10-12-a871a9)

🤖 Generated with Claude Code

tino097 and others added 2 commits October 12, 2026 15:51
…ntext, not "(none)".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…p the engine fallback out of the catalog label.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T14:12:33.305547Z c1c67d9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tino097
tino097 requested review from StpMax and ea-rus October 12, 2026 14:17
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@StpMax StpMax left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned that if two connections have the same label, it could cause problems. Below is the agent's comment on this:

**1. It breaks the uniqueness rule the rest of the code keeps.** Both anton and cowork-server pass every stored label through `ensure_unique_user_label`, which is unique across the whole vault, not per engine. That is why the old default was `postgres 2`. The fallback here bypasses the rule.

**2. Duplicates are not limited to two unnamed connections.** `ensure_unique_user_label` only sees stored labels, not the fallback. Example:
- connection A is created from a cowork form with no name → the prompt shows `Label: postgres` (fallback);
- connection B is created by the agent through anton's `connect_datasource`, which still stores the engine id as `_user_label` (`anton/tools.py:221`). A has no stored label, so B is saved as `postgres`, not `postgres 2`.

Both connections now read `Label: postgres`, but only B's value is stored. The `connection_display_name` docstring in cowork-server#646 notes that `connect_datasource` still does this.

**3. The eval doesn't cover it.** `scm-trap-out-of-horizon` ran with a single unlabelled connection, so we don't know how the model behaves when two connections share a label.

**Suggestion:** make the fallback unique at render time with the same rule, so the model again sees `postgres` / `postgres 2`, as in the 8/8 baseline. A rough sketch:

    taken = set(_labels_by_connection(vault).values())  # or collect in a first pass
    ...
    label = user_label
    if not label:
        base = engine or slug
        label, n = base, 2
        while label in taken:
            label, n = f"{base} {n}", n + 1
        taken.add(label)

tino097 and others added 2 commits October 13, 2026 17:21
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tino097

tino097 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in fd33d3f and 737b441. The fallback now goes through the same suffix rule as ensure_unique_user_label, with stored labels counted as taken, so your A/B case renders postgres 2 / postgres. Fallbacks are assigned oldest first, so a new connection never renames one the model already knows. One difference from the sketch: uniqueness is checked against the connections in the prompt, not the whole vault, because the slugs filter promises not to read records it leaves out. The cost is that an active datasource's fallback can match a hidden connection's stored label, which the model never sees side by side. I haven't rerun the eval with two unnamed connections yet.

@tino097
tino097 requested a review from StpMax October 14, 2026 14:55
@tino097

tino097 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Eval rerun on 737b441 with two unnamed connections (postgres / postgres 2): out-of-horizon 6/8 by the judge, and the same refs with one unnamed connection also give 6/8. The second connection makes no difference; neither run asked which connection to use or touched the second one.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tino097
tino097 merged commit 2b2cb93 into staging Oct 15, 2026
9 checks passed
@tino097
tino097 deleted the tino097/eng-1706-a-handcrafted-connector-form-discards-the-engine-it-declared branch October 15, 2026 09:22
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants