You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow-up to #161, which was closed saying get_session_info() would return the AI-generated title via SDKSessionInfo.summary / custom_title (available since SDK v0.1.50+).
In practice it doesn't. For sessions driven by the Python SDK, get_session_info() never returns an AI-generated title — it falls back to the first prompt. The bundled CLI never writes the {"type":"ai-title", ...} line into the session JSONL during SDK-driven sessions, so there is nothing for get_session_info() to surface.
The read side (_internal/sessions.py) is fine — it does look for aiTitle and exposes it through custom_title. The bug is the write side: that line is never created.
Reproduction
SDK: claude-agent-sdk0.1.60
Bundled CLI: cli.js2.1.111
Python 3.11.13, Linux
importasynciofrompathlibimportPathfromclaude_agent_sdkimport (
ClaudeAgentOptions,
ClaudeSDKClient,
ResultMessage,
get_session_info,
)
asyncdefmain():
cwd=Path.cwd()
asyncwithClaudeSDKClient(options=ClaudeAgentOptions(cwd=str(cwd))) asclient:
awaitclient.query("Tell me about Python and its history")
session_id=Noneasyncformsginclient.receive_response():
ifisinstance(msg, ResultMessage):
session_id=msg.session_idinfo=get_session_info(session_id, directory=str(cwd))
print(repr(info.summary)) # -> "Tell me about Python and its history"print(repr(info.custom_title)) # -> Noneasyncio.run(main())
grep ai-title <session>.jsonl returns nothing — even after long sessions, even after await asyncio.sleep(100) before exit.
Workaround
The CLI does support an explicit control request that generates and persists the title. We can fire it right after client.query() so the title is fetched in parallel with the assistant response:
asyncwithClaudeSDKClient(options=options) asclient:
awaitclient.query(prompt)
# Fire title generation now; runs concurrently with the assistant turn.title_task=asyncio.create_task(
client._query._send_control_request(
{
"subtype": "generate_session_title",
"description": prompt,
"persist": True,
}
)
)
asyncformsginclient.receive_response():
ifisinstance(msg, ResultMessage):
session_id=msg.session_idresult=awaittitle_taskprint(result["title"])
# Now get_session_info() returns the AI title:info=get_session_info(session_id, directory=str(cwd))
assertinfo.custom_title==result["title"]
This works reliably and the ai-title line is on disk by the time the call returns. But _query._send_control_request is private and the generate_session_title subtype isn't in the SDKControlRequest union, so we'd rather not depend on it.
What we'd like
Confirm whether there's a public API we missed for getting the AI-generated title from the SDK. We checked the public exports (get_session_info, list_sessions, rename_session, and the methods on ClaudeSDKClient) and didn't find one.
If not, please add a public client.get_session_title() method that generates the title in parallel with the assistant response — the way the CLI's interactive UI already does it (it just doesn't persist the result to the JSONL).
With that in place, please make get_session_info() actually return the AI title for SDK-driven sessions, so the resolution from Get summarized title of the chat #161 holds.
Problem
Follow-up to #161, which was closed saying
get_session_info()would return the AI-generated title viaSDKSessionInfo.summary/custom_title(available since SDKv0.1.50+).In practice it doesn't. For sessions driven by the Python SDK,
get_session_info()never returns an AI-generated title — it falls back to the first prompt. The bundled CLI never writes the{"type":"ai-title", ...}line into the session JSONL during SDK-driven sessions, so there is nothing forget_session_info()to surface.The read side (
_internal/sessions.py) is fine — it does look foraiTitleand exposes it throughcustom_title. The bug is the write side: that line is never created.Reproduction
claude-agent-sdk0.1.60cli.js2.1.111grep ai-title <session>.jsonlreturns nothing — even after long sessions, even afterawait asyncio.sleep(100)before exit.Workaround
The CLI does support an explicit control request that generates and persists the title. We can fire it right after
client.query()so the title is fetched in parallel with the assistant response:This works reliably and the
ai-titleline is on disk by the time the call returns. But_query._send_control_requestis private and thegenerate_session_titlesubtype isn't in theSDKControlRequestunion, so we'd rather not depend on it.What we'd like
Confirm whether there's a public API we missed for getting the AI-generated title from the SDK. We checked the public exports (
get_session_info,list_sessions,rename_session, and the methods onClaudeSDKClient) and didn't find one.If not, please add a public
client.get_session_title()method that generates the title in parallel with the assistant response — the way the CLI's interactive UI already does it (it just doesn't persist the result to the JSONL).With that in place, please make
get_session_info()actually return the AI title for SDK-driven sessions, so the resolution from Get summarized title of the chat #161 holds.