<command-name>/ide</command-name> <command-message>ide</command-message>…
- User
/ide ide
- User
can we check when we fill the first prompt field in sessionState?
Assistant
Let me find where
SessionStateis defined and where its prompt field gets set.Assistant
Now let me look at where
FirstPromptgets set during session initialization - the key entry points:Assistant
Now let me trace who calls
InitializeSessionto see where theuserPromptcomes from:Assistant
The key call site is in the hook handlers. Let me look at the Claude Code handler:
Assistant
Now let me check where
hookData.input.UserPromptcomes from - the hook input structure:Assistant
Now let me see where
UserPromptgets populated in the agent implementations - specifically for Claude Code:Assistant
Interesting — only Gemini sets
UserPromptdirectly. Let me check how Claude Code populates theHookInput:Assistant
There it is. Let me also check the
sessionInfoRawstruct to confirm there's no prompt field:Assistant
Now I have the full picture. Here's what's happening:
For Claude Code,
FirstPromptis never populated duringInitializeSession.The flow is:
user_prompt_submithook fires →captureInitialState()(hooks_claudecode_handlers.go:63)- It calls
InitializeSession(sessionID, agentType, sessionRef, hookData.input.UserPrompt)(line 80) hookData.inputcomes fromParseHookInput()(claude.go:84)- For
HookUserPromptSubmit, it parsessessionInfoRawwhich only hassession_idandtranscript_path— no prompt field (types.go:33-36) - So
input.UserPromptis always""for Claude Code
Compare with Gemini CLI (
gemini.go:132) which explicitly sets .- User
you are not correct: "In addition to the common input fields, UserPromptSubmit hooks receive the prompt field containing the text the user submitted." -> https://code.claude.com/docs/en/hooks#userpromptsubmit-input
Assistant
You're right, my mistake. So Claude Code does send a
promptfield in theuser-prompt-submithook input — we're just not parsing it. ThesessionInfoRawstruct is missing the field.Let me look at the current state to confirm the fix needed:
Assistant
Two things needed:
-
sessionInfoRaw(types.go:33) is missing thepromptfield — but it's shared acrossSessionStart,UserPromptSubmit, andStop, and onlyUserPromptSubmithas the prompt. Adding the field is fine since JSON unmarshalling just ignores missing fields. -
ParseHookInput(claude.go:102) doesn't setinput.UserPromptfrom the parsed data.
-
Assistant
Fair point. Let me split the types properly.
Assistant
Now update
ParseHookInputto use the new type forUserPromptSubmit:Assistant
The LSP warning is a false positive — it's used in
claude.goin the same package. Let me verify the tests pass:Assistant
Compiles cleanly. Let me check if there are existing tests for
ParseHookInput:Assistant
No existing tests for
ParseHookInput. Let me run the existing tests to make sure nothing breaks:Assistant
All passing. Let me write a test to cover this new behavior:
Assistant
I'll add a
claude_test.gofile with tests forParseHookInput:Assistant
Both tests pass. Now let me run the full test suite to make sure nothing else broke:
Assistant
All green. Here's a summary of the changes:
Problem: Claude Code's
user-prompt-submithook sends apromptfield with the user's prompt text, but we weren't parsing it. ThesessionInfoRawstruct only hadsession_idandtranscript_path, soFirstPromptinSessionStatewas always empty for Claude Code sessions.Fix (2 files):
-
types.go— SplitsessionInfoRawinto two types: keptsessionInfoRawforSessionStart/SessionEnd/Stop, addeduserPromptSubmitRawwith thePromptfield. -
claude.go— GaveHookUserPromptSubmitits own case branch inParseHookInputthat parsesuserPromptSubmitRawand setsinput.UserPrompt = raw.Prompt. -
claude_test.go(new) — Tests thatUserPromptSubmitcorrectly extracts the prompt and thatSessionStartleavesUserPromptempty.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.