Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,11 @@ class Session(BaseModel):
- Preserves exact project-scoped ID capture, post-exit DAF title updates, and fail-closed timeout/ambiguity handling
- Adds slow-query, timeout, title, project-scope, and reopen-budget regression coverage

- ✓ Kilo interactive title recovery (itdove/devaiflow#692)
- Retries project-scoped post-capture title synchronization once after a transient API failure
- Preserves exact DAF session names after title pre-creation failures without guessing when native identity is unavailable
- Adds recovery, retry, scoping, resume, and no-ID regression coverage

- ✓ Immediate model provider persistence in `daf config edit` (itdove/devaiflow#688)
- Saves newly added model provider profiles as soon as the add flow completes
- Saves default profile selections immediately while preserving enforcement restrictions
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Gives Kilo's version detection and session-list startup a bounded 10-second budget instead of OpenCode's 2-second budget
- Preserves exact project-scoped ID capture and post-exit DAF title updates for full-TUI launches
- Keeps query failures, timeouts, and ambiguous candidates fail-closed without guessing a native identity
- **Recover Kilo interactive session titles after transient API failures** (#692)
- Retries the project-scoped post-capture title update once before reporting that synchronization was unavailable
- Captures and persists the exact DAF session name when pre-creation fails, without guessing when no native ID is verified
- **Persist model provider changes immediately** (#688)
- `daf config edit` now saves a newly added model provider profile as soon as the add flow completes
- Setting a model provider profile as the default is persisted immediately
Expand Down
29 changes: 23 additions & 6 deletions devflow/agent/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,12 +887,29 @@ def remember_session_id(native_id: str) -> None:
title_env = dict(env or {})
if managed_path:
title_env["KILO_NO_DAEMON"] = "1"
agent.update_session_title(
captured_native_id,
display_name,
project_path,
title_env,
)
title_updated = False
for attempt in range(2):
try:
title_updated = agent.update_session_title(
captured_native_id,
display_name,
project_path,
title_env,
)
except (OSError, RuntimeError, ValueError):
logging.getLogger(__name__).debug(
"Unable to synchronize the captured Kilo session title",
exc_info=True,
)
if title_updated:
break
if attempt == 0:
time.sleep(0.1)
if not title_updated:
logging.getLogger(__name__).warning(
"Unable to synchronize the captured Kilo session title; "
"the native session remains available"
)
if (
not launch_failed
and session
Expand Down
13 changes: 8 additions & 5 deletions devflow/cli_skills/daf-workflow/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ The **DAF session name** (`Name` in `daf info`) identifies the session; the
**goal** (`--goal`) describes the work; the backend's **LLM conversation title**
is separate display metadata.

For **Claude Code, Pi, and OpenCode**, DAF manages native title setting at launch
and on supported resume paths. The title is the **exact current DAF session
name** from metadata, not the goal, issue summary, or an agent-generated task
summary. This applies to `daf new`, `daf open`, `daf git new`, `daf jira new`,
and `daf investigate`; read-only and ticket-creation constraints still apply.
For **Claude Code, Pi, OpenCode, and Kilo**, DAF manages native title setting at
launch and on supported resume paths. The title is the **exact current DAF
session name** from metadata, not the goal, issue summary, or an agent-generated
task summary. Kilo full-TUI launches may apply the title after a verified,
project-scoped session capture and retry that update once if the title API is
temporarily unavailable. This applies to `daf new`, `daf open`, `daf git new`,
`daf jira new`, and `daf investigate`; read-only and ticket-creation constraints
still apply.

Do not independently rename the conversation from `--goal`, rename the DAF
session, or duplicate DAF's launch/resume title-setting operations. Other
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/ai-agent-support-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ synchronizes the title where the agent supports it.
| Claude Code | `--name` on new-session launches and `daf open` resumes |
| Pi | `--name` on new-session launches and resumes |
| OpenCode | Version-compatible session create/update API; `run --title` for headless launches |
| Kilo Code | Session create/update API; `kilo run --title` fallback for new sessions |
| Kilo Code | Session create/update API; `kilo run --title` fallback for new sessions; one bounded retry for post-capture updates |

Other adapters (including Ollama, Codex, Aider, Crush, Continue, Copilot,
Cursor, and Windsurf) do not currently expose a stable title-setting mechanism
Expand Down Expand Up @@ -936,7 +936,7 @@ version detection, commands, database locations, and clone-isolation behavior.
| --- | --- | --- |
| Launch and resume | Kilo 7.8.27's root command `kilo [project]` starts the full TUI and supports `--session`, `--model provider/model`, `--prompt`, and `--auto`. `kilo run --interactive` is the direct split-footer interface; `kilo run --format json` is headless and supports `--variant`. The root TUI has no launch-time `--variant` option. | The adapter uses the root command for interactive launch/resume and the `run` command for headless JSON launches. Provider/model, prompt, session, auto-approval, and managed-clone settings are retained; headless variants remain passed through. Interactive reasoning variants must be selected in Kilo's TUI. |
| Session listing and capture | `kilo session list --format json --all` returns records with IDs and directory metadata; on a successful empty result it may print no JSON. | Kilo queries use a bounded 10-second budget that includes version detection and CLI startup, are scoped by canonical project directory, and treat successful empty output as empty only after a zero exit code. Query errors and ambiguous new sessions fail closed. |
| Interactive titles | The root TUI has no CLI `--title` option. Kilo's local HTTP API supports session create/update; the DAF adapter uses a short-lived `kilo serve` process with `KILO_NO_DAEMON=1`. Create and rename were smoke-tested on Kilo 7.8.27. | For full-TUI launches with an initial prompt, DAF lets Kilo create the session from its home route, captures and persists the unique project-scoped ID after exit, then best-effort applies the DAF title. Passing `--session` would route away from home and prevent Kilo from auto-submitting `--prompt`. Other interactive launches can still pre-create titled sessions; resume title updates remain best-effort. |
| Interactive titles | The root TUI has no CLI `--title` option. Kilo's local HTTP API supports session create/update; the DAF adapter uses a short-lived `kilo serve` process with `KILO_NO_DAEMON=1`. Create and rename were smoke-tested on Kilo 7.8.27. | For full-TUI launches with an initial prompt, DAF lets Kilo create the session from its home route, captures and persists the unique project-scoped ID after exit, then applies the DAF title with one bounded retry. Passing `--session` would route away from home and prevent Kilo from auto-submitting `--prompt`. Other interactive launches can still pre-create titled sessions; resume title updates remain best-effort. If capture cannot verify a unique project-scoped ID, DAF does not guess or rename another session. |
| Managed-clone isolation | Kilo documents `KILO_NO_DAEMON` to disable automatic attachment to its persistent local daemon. Its CLI does not expose OpenCode v2's `--standalone`. | The adapter sets `KILO_NO_DAEMON=1` for managed-clone interactive/headless launches, resumes, session queries, exports, and its private title API server. DAF's generic live-holder completion guards remain in force; real model-backed clone process-tree behavior still needs end-to-end validation. Never stop or evict a shared Kilo daemon. |
| Export and message counts | `kilo export <sessionID>` emits JSON by default and has no `--format` option; tested output contains a `messages` array. | DAF counts exported messages using Kilo's actual command/output. Portable DAF transcript backup/import remains unavailable because Kilo stores sessions in a shared database rather than per-session transcript files. |
| Token statistics | `kilo stats` is human-readable and has no JSON format option in the evaluated CLI. | Structured token usage remains unavailable; the adapter reports `None` rather than parsing display text or reusing OpenCode's `stats --format json`. |
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/alternative-model-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ the initial context with `--prompt`. Kilo 7.8.27 auto-submits that option from
the new-session home route; adding `--session` routes directly to the existing
session and skips that submission. DAF therefore lets Kilo create the initial
prompted session, captures its unique project-scoped ID after the TUI exits, and
then best-effort applies the DAF session title. Do not use
applies the DAF session title with one bounded retry. Do not use
`kilo run --interactive` for this workflow: that flag selects Kilo's split-footer
interface. Headless DAF launches continue to use `kilo run --format json`;
configured reasoning variants are passed to headless runs. Kilo's full TUI
Expand Down
2 changes: 1 addition & 1 deletion tests/test_daf_workflow_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_title_policy_preserves_backend_capabilities_and_reports_mismatches() ->
"""Keep unsupported titles agent-managed and report failures without fallbacks."""
section = _title_policy_section()

assert "For **Claude Code, Pi, and OpenCode**" in section
assert "For **Claude Code, Pi, OpenCode, and Kilo**" in section
assert "Other backends retain their normal agent-managed titles" in section
assert (
"If a supported backend's title does not match, report a **title-propagation problem**"
Expand Down
126 changes: 126 additions & 0 deletions tests/test_kilo_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,132 @@ def fake_launch(project_path, **kwargs):
)


def test_kilo_title_sync_retries_after_transient_update_failure(
agent, monkeypatch, tmp_path
):
process = Mock(returncode=0)
session_queries = []

def list_sessions(*args, **kwargs):
session_queries.append((args, kwargs))
return set() if len(session_queries) == 1 else {"ses_created"}

agent.get_existing_sessions = Mock(side_effect=list_sessions)
agent.wait_for_exit = Mock()
update_title = Mock(side_effect=[False, True])
agent.update_session_title = update_title

def fake_launch(project_path, **kwargs):
kwargs["on_launch"]()
return process

agent.launch_with_prompt = fake_launch
monkeypatch.setattr("devflow.agent.factory.time.sleep", lambda _seconds: None)
conversation = SimpleNamespace(
ai_agent_session_id="pending-capture",
temp_directory=None,
worktree_path=None,
)

launch_and_capture(
agent,
"kilo",
str(tmp_path),
conversation,
initial_prompt="initial prompt",
session_id="pending-capture",
env={"EXISTING": "yes"},
display_name="daf-session",
)

assert conversation.ai_agent_session_id == "ses_created"
assert update_title.call_count == 2
assert all(
call.args
== (
"ses_created",
"daf-session",
str(tmp_path),
{"EXISTING": "yes"},
)
for call in update_title.call_args_list
)


def test_kilo_title_sync_recovers_when_precreation_fails(agent, monkeypatch, tmp_path):
process = Mock(returncode=0)
popen = Mock(return_value=process)
session_queries = []

def list_sessions(*args, **kwargs):
session_queries.append((args, kwargs))
return set() if len(session_queries) == 1 else {"ses_created"}

monkeypatch.setattr("devflow.agent.kilo_agent.require_tool", lambda *args: None)
monkeypatch.setattr("devflow.agent.kilo_agent.subprocess.Popen", popen)
monkeypatch.setattr("devflow.agent.factory.time.sleep", lambda _seconds: None)
agent._create_session_with_title = Mock(return_value=None)
agent.get_existing_sessions = Mock(side_effect=list_sessions)
agent.wait_for_exit = Mock()
agent.update_session_title = Mock(return_value=True)
conversation = SimpleNamespace(
ai_agent_session_id="pending-capture",
temp_directory=None,
worktree_path=None,
)

launch_and_capture(
agent,
"kilo",
str(tmp_path),
conversation,
initial_prompt="",
session_id="pending-capture",
env={"EXISTING": "yes"},
display_name="daf-session",
)

assert popen.call_args.args[0] == ["kilo"]
agent._create_session_with_title.assert_called_once()
agent.update_session_title.assert_called_once_with(
"ses_created", "daf-session", str(tmp_path), {"EXISTING": "yes"}
)


def test_kilo_title_sync_skips_when_native_id_cannot_be_captured(
agent, monkeypatch, tmp_path
):
process = Mock(returncode=0)
agent.get_existing_sessions = Mock(return_value=set())
agent.wait_for_exit = Mock()
agent.update_session_title = Mock(return_value=True)

def fake_launch(project_path, **kwargs):
kwargs["on_launch"]()
return process

agent.launch_with_prompt = fake_launch
monkeypatch.setattr("devflow.agent.factory.time.sleep", lambda _seconds: None)
conversation = SimpleNamespace(
ai_agent_session_id="pending-capture",
temp_directory=None,
worktree_path=None,
)

launch_and_capture(
agent,
"kilo",
str(tmp_path),
conversation,
initial_prompt="initial prompt",
session_id="pending-capture",
display_name="daf-session",
)

assert conversation.ai_agent_session_id == "pending-capture"
agent.update_session_title.assert_not_called()


def test_resume_session_uses_kilo_session_flag_and_updates_title(
agent, monkeypatch, tmp_path
):
Expand Down
Loading