Skip to content

fix(sdk): pair the first-task rename_agent call to rename_session - #5908

Merged
mmabrouk merged 2 commits into
release/v0.112.0from
fix/rename-agent-pairing
Aug 10, 2026
Merged

fix(sdk): pair the first-task rename_agent call to rename_session#5908
mmabrouk merged 2 commits into
release/v0.112.0from
fix/rename-agent-pairing

Conversation

@mmabrouk

Copy link
Copy Markdown
Member

Context

Live debugging of a real session showed a freshly created agent renaming its session perfectly ("Daily Arabic Poetry") while never once attempting rename_agent, leaving the agent named "Create an agent that sends me a telegram message". The tool was available and auto-allowed, and the guidance even named "you were just created" as a trigger; as an independent judgment call the model reliably forgot it. The benchmark had already measured this residual (1 of 3 genuine misses on the agent-naming scenario).

Changes

rename_agent is no longer a standalone clause. The default persona's rename_session bullet now carries the pairing: if this is the agent's first task since creation (its name still a raw request or a placeholder), also call rename_agent in the same turn. The standalone bullet shrinks to the later repurposing case. Both drift-locked copies (SDK _DEFAULT_AGENTS_MD and the services fallback) move together, and the drift-lock tests pin the pairing phrase.

New benchmark scenario name-06-composer-first-task mirrors the real composer path: the workflow seeded with the raw request as its name (carrying a per-trial token), the session seeded with the client auto-title, both ops mounted, verbatim persona. It requires each rename exactly once and proves the raw-request name was replaced (the token must disappear).

Validation (full self_naming run, 18 trials, results in the repo)

Scenario Result
name-06 pairing attempts 3/3 — the model now calls BOTH renames in the same turn every time
name-04 no-spurious-rename 3/3 clean, zero rename calls (the guard this change must not break)
name-05 default persona 3/3 one-shot, holds
name-01..03 hold at their baselines (misses attributed to the known harness tool quirk, zero check failures)

name-06's stored-name check passed 1 of 3: the two failures are NOT behavior — both trials attempted correctly and hit a newly exposed backend race where the second side-effecting call's result goes unobserved when the turn's pause ends (#5907, characterization in progress). The scenario stays in as the standing guard and goes fully green when that race is fixed.

Tests

SDK unit 2024 passed (including the extended drift locks), services unit 101 passed, scenario JSON validated, CI-pinned ruff clean.

…o rename_session

A live composer session showed the residual name-03 also measures: a
post-reinforcement agent (new persona verbatim, rename_agent mounted and
auto-allowed) called rename_session perfectly and still left 'Create an
agent that sends me a telegram message' as its name. As a standalone
'when your purpose changes' judgment call the model reliably forgets
rename_agent, so the persona now pairs it to the reliable call: the
rename_session bullet adds 'if this is also your first task since you
were created — your agent name is still a raw request or a placeholder —
also call rename_agent in the same turn', and the standalone bullet
shrinks to the later repurposing case. Both drift-locked copies (SDK
_DEFAULT_AGENTS_MD and the services config.py fallback) move together.

name-06-composer-first-task measures the pairing on the real composer
shape: the workflow seeded with the raw request as its name, the session
seeded with the client-auto-title truncation of the first message, both
rename ops mounted, and rename_session AND rename_agent each expected
exactly once — max_rename_calls is a single combined counter across both
rename tools, so 2 plus the two min-1 tool checks pins one call each.
The stored workflow name must lose the seeded raw request (a negative
lookahead on the per-trial token) and keep is_application. name-03's
header-seed shortcut stays.
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Aug 10, 2026
@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Error Error Aug 10, 2026 2:59pm

Request Review

@dosubot dosubot Bot added the enhancement New feature or request label Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 079d1463-4898-4894-bb26-f2c4d995752e

📥 Commits

Reviewing files that changed from the base of the PR and between 0ecb6e8 and 86c32c0.

📒 Files selected for processing (1)
  • benchmarks/agent-config-editing/scenarios/09-self-naming.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • benchmarks/agent-config-editing/scenarios/09-self-naming.json

📝 Walkthrough

Summary by CodeRabbit

  • Improvements

    • Agents with temporary or placeholder names are now guided to choose meaningful agent and session names during their first task.
    • Subsequent renaming is limited to genuine changes in identity or purpose, reducing unnecessary name updates.
  • Quality

    • Expanded validation for agent and session naming behavior across default scenarios.

Walkthrough

The default persona now pairs first-task rename_agent and rename_session calls for raw or placeholder names. Tests and a new composer benchmark validate the shared call budget and resulting names.

Changes

First-task self-naming

Layer / File(s) Summary
Default persona rename guidance
sdks/python/agenta/sdk/utils/types.py, services/oss/src/agent/config.py, sdks/python/oss/tests/pytest/unit/agents/test_default_persona_self_naming.py
Default instructions require paired initial renames and restrict later agent renames to identity or purpose changes. Unit assertions verify the guidance.
Composer first-task benchmark
benchmarks/agent-config-editing/scenarios/09-self-naming.json, sdks/python/oss/tests/pytest/unit/agents/test_default_persona_self_naming.py
A new scenario validates both rename tools, a combined two-call budget, and task-based session and workflow names. The benchmark test covers both self-naming scenarios.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Composer
  participant rename_agent
  participant rename_session
  participant Scenario
  Composer->>rename_agent: Rename the placeholder agent
  Composer->>rename_session: Rename the raw session
  Scenario->>Composer: Verify the combined two-call budget
  Scenario->>rename_agent: Verify the workflow name
  Scenario->>rename_session: Verify the session name
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: pairing the first-task rename_agent call with rename_session.
Description check ✅ Passed The description directly explains the persona updates, benchmark scenario, validation results, and backend race affecting stored-name checks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/rename-agent-pairing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: c4205f64-27ae-4f89-b4b1-d13d0fe9ecd7

📥 Commits

Reviewing files that changed from the base of the PR and between e6e999b and 0ecb6e8.

📒 Files selected for processing (4)
  • benchmarks/agent-config-editing/scenarios/09-self-naming.json
  • sdks/python/agenta/sdk/utils/types.py
  • sdks/python/oss/tests/pytest/unit/agents/test_default_persona_self_naming.py
  • services/oss/src/agent/config.py

Comment thread benchmarks/agent-config-editing/scenarios/09-self-naming.json
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Preview URL https://gateway-pr-5908.up.railway.app/w
Project agenta-oss-clone-spike
Image tag pr-5908-9e6daa2
Status Deployed
Railway logs Open logs
Workflow logs View workflow run
Updated at 2026-08-10T15:13:15.102Z

The session pattern passed on the seeded truncation (it contains 'standup
summary') and the workflow check only rejected the token segment, so a
failed persist could still pass. Both stored names must now differ from
their seeds: the session name must not open with the seeded truncation,
and the workflow name must not contain the raw request stem.
@mmabrouk mmabrouk added the lgtm This PR has been approved by a maintainer label Aug 10, 2026
@mmabrouk
mmabrouk merged commit f4f8ff9 into release/v0.112.0 Aug 10, 2026
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant