Skip to content

fix: forward Claude Code session_id and permission_mode to backend #33

@tumberger

Description

@tumberger

Problem

Two fields from Claude Code's hook stdin JSON are parsed but dropped before reaching the backend:

1. Claude Code's native session_id

  • Parsed by the claude adapter in DecodeHookInput
  • Stored in agent.HookEvent.SessionID
  • Dropped in main.go's evaluateViaSidecar() — the EvaluateRequest struct has no SessionID field
  • The Kontext session ID is used instead, so Claude Code's own session identity is lost

2. permission_mode

  • Parsed by the claude adapter's hookInput struct
  • Dropped at the adapter layer — never transferred to agent.HookEvent
  • This field indicates whether Claude Code is running in default, plan, or bypassPermissions mode — important security context

Impact

  • Cannot correlate Kontext events back to a specific Claude Code session (matters when multiple Claude instances share a Kontext session)
  • No visibility into whether the agent was running with permissions bypassed — critical for audit/compliance

Fix

  1. Add SessionID and PermissionMode fields to sidecar.EvaluateRequest
  2. Add corresponding fields to the proto ProcessHookEventRequest
  3. Store both in the events table

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions