Repository navigation
feat: add chat_rename so an agent can rename its own session - #33736
Conversation
b4464dc to
e0638a9
Compare
e0638a9 to
ebcb448
Compare
|
Updated to the RFC as accepted in #33633, rebased onto Two commits:
An end-to-end run on a harness gateway with a real model passed every step in the body's Manual verification. AI-assisted, sent by Kiro Crew |
ebcb448 to
d1e3f14
Compare
|
Ready for review at @bolichen97, could you approve the fork runs here and on #34667, and review both when they're green? AI-assisted, sent by Kiro Crew |
Bolin Chen accepted the chat_rename tool as designed in an approving review of kirodotdev#33633. Record it in the RFC's Sign-off section and its index row, and move the status to in-progress, since kirodotdev#33736 implements it. Whether a conductor may reach the tool behind its approval prompt stays open for the owner: the review leaves it out.
Bolin Chen accepted the chat_rename tool as designed in an approving review of kirodotdev#33633. Record it in the RFC's Sign-off section and its index row, and move the status to in-progress, since kirodotdev#33736 implements it. Whether a conductor may reach the tool behind its approval prompt stays open for the owner: the review leaves it out.
d1e3f14 to
9a0c03d
Compare
Code change approver recommendation: A person should decideWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, but it changes 2112 lines, more than the 400 it may approve on its own. Adds a An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
@bolichen97, could you approve and merge #34667 once its CI finishes? I'll push the rebase here right after. That push also adds the reader list PR Hygiene asks for, and re-runs Security Scope Review, whose job failed to connect to github.com. AI-assisted, sent by Kiro Crew |
Bolin Chen accepted the chat_rename tool as designed in an approving review of #33633. Record it in the RFC's Sign-off section and its index row, and move the status to in-progress, since #33736 implements it. Whether a conductor may reach the tool behind its approval prompt stays open for the owner: the review leaves it out.
aaef1d8 to
f5bdcdf
Compare
|
Rebased onto @bolichen97, thanks for merging #34667. Could you approve the runs for this head? AI-assisted, sent by Kiro Crew |
|
@bolichen97, thanks for approving the runs. On this head the review lanes pass (Design, First Principles, Opus, GPT and Security Scope), and so does PR Hygiene; four backend test shards are still running. AI-assisted, sent by Kiro Crew |
f5bdcdf to
d281d61
Compare
|
The two red tests on the previous head were AI-assisted, sent by Kiro Crew |
d281d61 to
2947911
Compare
|
Rebased onto today's @bolichen97, could you approve the runs for this head when you get a chance? AI-assisted, sent by Kiro Crew |
chat_title.py sits one line under the 2,000-line cap, so the next change to it cannot land. The explicit-title paths (the rename route and apply_manual_title, and "Regenerate title" with generate_manual_title and apply_regenerated_title) move to chat_title_explicit.py, unchanged but for one comment's wording, and _facade_compose runs them on chat_title's globals. chat_title stays their import path and patch target, so no caller or test changes; a composition test pins that. name_member_thread stays in chat_title with its redaction, so the security posture's module list is unchanged.
An agent on the default spec cannot rename the session it runs in: session_rename lives in the opt-in kirocrew-dashboard server, which the default spec does not mount, and it needs a target the agent cannot learn. chat_rename is a kirocrew-core session directive, shaped like chat_tag, that renames only the calling session, under session_rename's title rules and refusals. Only a turn the person sent may rename. Beyond the user-origin gate, it requires a person's turn actor, a turn the dashboard still counts as user-sent, and no channel provenance, so a script cron's send_to_session turn and a turn another session, an app or a channel steered into are refused. A channel's own tab is refused whether or not it is bound yet, and so is a conductor's session (Crew Mode or a crewmate's own chat) until the owner decides whether conductors may rename themselves. It never replaces a title someone set by hand. The title it writes carries a new origin, "agent", which the background titler treats as final and Slack listings read as typed text; a person's later rename replaces it, and "Regenerate title" hands the name back. Each applied rename writes the chat.manual_rename audit row every rename writes. Incognito and temporary sessions can rename themselves too. Implements docs/request-for-change/rfc-agent-self-rename.md.
2947911 to
54ea1a8
Compare
|
@bolichen97, rebased onto today's
The local gates pass on this head. Its runs need a maintainer's approval, then a review. AI-assisted, sent by Kiro Crew |
bolichen97
left a comment
There was a problem hiding this comment.
Approving at 54ea1a89d1. I did one deep pass over the tool, the applier and the title-origin change, and checked them against the accepted RFC (#33633, Sign-off item 1).
What I checked
- Self-only.
chat_renamecarries no target. The dispatcher applies it to the slot that produced the turn, and_apply_chat_renamere-checks that the slot is still live (state._slots.get(slot.key) is slot, not closing) before the probe and again after it, with no await between the second check and the write. Another session, an app or a cron cannot reach a person's session through it. - Person's turn only. The tool is in
USER_SURFACE_DIRECTIVES, and the applier also requires an actor in_PERSON_ACTORS,_turn_user_sent is True, and neither channel flag. I checked that every slot attribute it reads throughgetattris a real field on_ChatSlot(_turn_user_sent,_turn_channel_origin,_turn_channel_narrowed,channel_origin, theis_closingproperty), so no check falls back to a silent default. - A person's title is never replaced.
_AGENT_REPLACEABLE_ORIGINSis an allowlist (auto,member,agent), so a titled slot with no recorded origin is refused asmanual_title. Every reader of_title_origintreatsagentas final (the refresh paths compare againstauto,name_member_threadkeeps it, the fork maps it touser), and an older build reads it asuser. - Input. The title goes through the existing
_clean_rename_title(1 to 200 chars after stripping, no control, bidi or hidden characters, redaction). The schema bound matchesSESSION_RENAME_SCHEMA. The audit line logs only the length or the refusal code, never the title. - Conductors are refused (
conductor_session) until Sign-off item 2 is decided, and an unreadable execution record fails closed.allow_ephemeralwaives only the memory-mode refusal. - Live update. The write goes through
apply_manual_title, which already broadcasts to the sidebar, so the frontend needs no change. - Split. The moved helpers keep their behaviour. The only change in the second commit is the
originkeyword, which is guarded with aValueErrorfor any value other thanuseroragent.
Ran locally on this head
- The 8 test files this PR adds or changes: 485 passed.
- Neighbouring rename, title and slot-ownership suites (
test_session_control_rename.py,test_dashboard_chat_session_meta.py,test_slot_ownership_checkpoint.py,test_file_line_cap.py,-k "rename or title or line_cap or family"): 231 passed. - flake8 and mypy on the 16 changed source files: clean. The file-line cap, comment-history and brand gates: pass.
Non-blocking notes
- RFC Sign-off item 2 (whether a conductor may reach
chat_rename) is still open. A team member has to make that design call. This PR is safe without it because it refuses conductors. chat_title.pyis at 1,818 lines, past the 1,600-line working target. This PR shrinks it, so this is only a heads-up for the next change there.
AI-assisted, sent by Bolin Review bot
Problem / Motivation
Goal: A person can ask the agent to rename the session it is running in, on the default agent and by a naming convention kept in their own instructions, without the agent ever replacing a name the person chose.
An agent on the default spec cannot rename its own session. The only agent-facing rename,
session_rename, lives in the opt-inkirocrew-dashboardserver, which the default spec does not mount, and it takes atargetthe agent has no way to learn. #13797 asked for a self-rename and was closed by #15164, which only helps agents that mount that server. So "name this session after the ticket" ends with the agent asking the person to rename it by hand.Why it matters
People with many open sessions find their work by the sidebar title, and many keep a naming convention in their own steering or lessons (#13797's example is
JIRA-XXXX — <ticket title>). Generated titles are often weak, which is why the dashboard has "Regenerate title"; the agent working in a session knows what it is about and can name it better. On the default agent it cannot do so at all, and an agent that could would have to leave a name the person typed alone.Not a goal
session_rename's job, unchanged: it still records originuserand may replace any title.conductor_session. An unattended self-rename for conductors (session_rename: add an auto-grantable self-only rename for conductors #17585) stays out either way./titlepath.What changed (motivation → approach → change)
Asking the agent to rename its session now works on the default agent in a normal dashboard chat, and the agent can never write over a name the person chose. The agent gets one new tool on
kirocrew-core, the server every session carries:chat_rename(title). It renames only the session whose turn called it, and only on a turn the person sent.It is built the way
chat_tagis: the tool returns a directive, and the dashboard applies it to the slot that produced the turn, so there is no session key to look up or get wrong. It reusessession_rename's pieces:_clean_rename_titlefor the title rules, the same refusal codes for a session it cannot reach, andapply_manual_title, the sidebar's own write, which records thechat.manual_renameaudit row with routechat_rename. The design is the accepted RFCdocs/request-for-change/rfc-agent-self-rename.md(#33633).A turn counts as the person's only when main's own checks agree: a person's actor,
slot._turn_user_sent, which the dashboard clears before a peer's or an app's text is steered in, and no channel provenance. Anything else is refused asnot_user_turn, a script cron'ssend_to_sessionturn included. A channel's tab is refused whether or not it is bound, and so are a conductor mode chat and a Bot's own chat, until the owner decides.Whose name a title is comes from the
title_originevery titled session already carries. The agent may replace an untitled session, a generated (auto) title, a Bot thread's name (member) or its own earlier rename, which records a new origin,agent. Every other titled origin is refused asmanual_title, a missing one included.agentis final for the background titler likeuser, and a person's rename replaces it. Incognito and temporary sessions can rename themselves.The first commit only moves the explicit-title helpers out of
chat_title.py, which this change would otherwise take past its 2,000-line cap.chat_renameinmcp_tools/control_parts/schemas.pyanddirective.py, wired inmcp_tools/control.py;CHAT_RENAME_SCHEMAinvalidation_parts/core_turn_schemas.py, registered invalidation_parts/server_registries.py, exported byvalidation.py; display title indata/mcp_tool_titles.jsonDIRECTIVE_TOOLS(session_directive.py) andUSER_SURFACE_DIRECTIVES(directive_origin.py): the existing gates refuse a slot-less caller and a turn without the user-origin mark;dashboard/session_directive_apply.pypasses the turn's actor on_apply_chat_renameindashboard/session_directive_apply_slot.py: title rules; the slot checks (live slot,_live_target_refusal, a channel's tab, a conductor mode chat, the person checks, the title origin); the execution-record read for a Bot's own chat and the mirror probe in worker threads; the slot checks again; then the writeagentand_AGENT_REPLACEABLE_ORIGINS; anoriginkeyword onapply_manual_title;name_member_threadkeeps anagenttitle; inmrkdwn_title.py,_TYPED_TITLE_ORIGINSgainsagentdashboard/chat_title_explicit.pyholdsgenerate_manual_title,apply_regenerated_title,api_chat_slot_generate_title,apply_manual_titleandapi_chat_slot_rename, composed ontochat_titlewith_facade_compose;name_member_threadand its redaction stay inchat_title.py_live_target_refusal(session_control_parts/target_authorization.py) takesallow_ephemeral, which waives only the memory-mode refusalchat.self_renamerecords the title length or the refusal code, never the title, and the allowed decision is recorded before the write; the tool's reply names each refused kind of turn and session;dashboard/chat_turn/directives.pygives the not-applied line, anddashboard/session_directive_apply_outcome.pynames the tool in its gate commentdocs/architecture/mcp.mdanddocs/feature-map/README.md;docs/system-specs/modules/(security.md,session.md,learn-cron-dashboard.md); the user docssrc/kiro_crew/docs/session-control.mdanddashboard.mdBackwards compatibility
Compatible: additive. No existing tool, route or default changes.
apply_manual_titlegains anoriginkeyword and_live_target_refusalanallow_ephemeralkeyword, both defaulting to today's behaviour, so every existing caller is unchanged. The moved helpers stay reachable aschat_title.<name>, and a test patch of achat_titleglobal still reaches them (test/test_chat_title_explicit_composition.py)._TITLE_ORIGINSaccepts one more value,agent, and every reader of atitle_originhandles it:_persist_titleand thetitle_originfield inslot_persistence/metadata_codec.pysave it, and_rehydrate_title_originrestores it as itself;_refresh_blocked,maybe_refresh_titleandrefresh_forked_titletreat it as final, likeuser;name_member_threadkeeps it, so a Bot's DM thread the agent renamed keeps that title instead of taking the Bot's display name when opened;_shape_fork_childgives the fork of anagent-titled session originuser;mrkdwn_title.stored_title_is_mrkdwnkeeps it as typed;_apply_chat_renamemay replace it. Three writers setuserdirectly and so replace anagenttitle, as a person's rename does: a fork child the caller names (session_control_parts/session_tree.py), a code-channel binding (slack/code_channels/binding.py) and a person's Slack thread rename (slack/agent_sessions/session_events.py). The frontend reads notitle_origin. A version that predatesagentreads a storedagentorigin asuser, which is final, so a downgrade cannot make an agent's title refreshable.The split takes five public defs out of
chat_title.py. Each of their readers onmainstill gets the same function; no app bundle, frontend file or script cron imports them, and the frontend calls the two routes by URL, which is unchanged:chatnames above; test_slot_ownership_checkpoint.py::TestEveryPerSlotRouteIsDecided::test_the_family_is_the_live_tableapply_regenerated_titleandgenerate_manual_titlebeside it; at run time_facade_mirrorserves thesession_titlesbinding, which test_chat_title_explicit_composition.py::test_an_old_import_path_binds_the_composed_function checksNothing else is taken away: the diff adds the tool, its schema, its applier, one title origin and one module; the edited pins add
chat_renamebeside the existing directive tools, andtest/test_title_refresh.pyswaps its example of an unknown origin fromagentto another word now thatagentis known.Tests
test/test_chat_rename_directive.py(new, 51 tests, 71 cases) locks in:cron,apporcrewis refused and actors""anduserrename; a turn with_turn_user_sentcleared by a peer's or an app's steer is refused; a channel-opened or channel-steered turn is refused, including after the session's mirror is removed;dashboard:slack_<ts>, while a person-madeslack_notestab renames;CONDUCTOR_TEMPLATESagent, a stamped conductor mode chat, a Bot's own chat and an unreadable execution record, while a worker a Bot opened and a default-agent chat rename;session_renameuses for a session it cannot reach, incognito and temporary sessions renaming themselves, and a title set by hand or given at creation with no recorded origin kept asmanual_title, before and after a reload;agentorigin through the real save and reload;chat.self_renameline never carrying the title, thechat.manual_renamerow with routechat_renameand both titles, and a close, a channel link or a person's rename landing during the mirror probe.test/test_chat_title_explicit_composition.py(new, 12 tests): the moved functions run onchat_title's globals with their signatures, every global they read is bound there, facade patches reach them, andchat_titlecomposes them once.test/test_slack_title_text.pykeeps anagenttitle as typed;test/test_title_refresh.pyrehydratesagentandmemberas themselves and an unknown origin asuser; pins updated intest/test_directive_tool_refusal_tagging.py,test/test_remote_session_local_only_tools.py,test/test_session_directive.pyandtest/test_validation_parts_facade.py.-n 4 --dist loadgroup, and a shuffled order (seed 6151).pre_push_gate.py's 24 checks (black, isort, flake8,mypy src/kiro_crew/, docs-lint and the file-line cap among them), the flake-pattern ratchet, the repository's semgrep rules on the diff (0 findings), 2,522 tests from the 41 suites that name the changed directive, title-origin and schema symbols plus the facade-mirror and file-line-cap guards, 1,429 tests from the 24 suites around the moved helpers, and 196 tests from the session-control and follow-up suites thatmainchanged besidetarget_authorization.pyandsession_directive_apply_slot.py. On an earlier base, the split commit alone passed the composition, security-posture,chat_title, member-thread, file-line-cap and facade-guard suites (433 tests); its own diff has since changed only by keepingmain's newprompt_handoffimport inchat_title.py.Manual verification
Run end to end on an earlier version of this branch, before its last rebases onto
mainand the wording updates for conductor mode and the redaction switch, on an isolated gateway from the repository's own harness (kiro_crew.testing.harness.spawn_feature_gateway,minimalfixture, approvalreads, loopback only). The default agent mounted this branch'skirocrew-core, a real model ran the turns, and each turn was sent as the dashboard user:DEMO-42 · agent self-rename@kirocrew-core/chat_rename; the title readsDEMO-42 · agent self-rename, originagentmanual_titleagentkirocrew-conductor, ask it to rename the session withchat_rename, and approve the promptconductor_session; title unchangedThe agent's own reply cannot confirm the outcome in the same turn: the rename is applied after the tool returns, so the tool tells the agent to report it as requested, and the result, a refusal included, shows in the tool row. The model does not always keep to that: after the
manual_titlerefusal above, its reply said the new name would show. A conductor still sees the tool and its approval prompt, because the conductor specs mountkirocrew-corewhole; the call is refused when it is applied. Asked only to rename its session, the conductor usedsession_renameinstead, from thekirocrew-dashboardserver the conductor specs mount, and renamed itself with originuserafter one approval; that ismain's behaviour, which this PR does not change.Related Issues
Closes #33624
RFC: #33633. Related: #13797, #15164, #17585, #20064, #27705, #13144.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)