Commit 6b21778
fix(backend): inherit parent userContext in child sessions (#988)
## Summary
- When a runner service account creates a child session, the child now
inherits the **parent session's `userContext`** instead of getting the
service account identity
- The runner API client automatically sets `parentSessionId` to the
current session name
- Fixes credential resolution (GitHub, Jira, etc.) for child sessions
## Problem
Child sessions created by a runner pod had `userContext.userId` set to
the service account identity (e.g.,
`system-serviceaccount-ns-ambient-session-session-123`). When the
backend tried to resolve GitHub credentials for the child, it looked up
credentials for the service account — which has none — returning 404.
## Changes
**`components/backend/handlers/sessions.go`**
- When `parentSessionId` is provided, fetch the parent session CR and
copy its `spec.userContext` to the child
- Falls back to existing identity resolution if no parent or parent
lookup fails
**`components/runners/ambient-runner/ambient_runner/tools/backend_api.py`**
- `create_session()` now automatically sets `parentSessionId` from
`AGENTIC_SESSION_NAME` env var
## Test plan
- [ ] Create a session that spawns child sessions — verify child
sessions have the parent's userId
- [ ] Verify child sessions can resolve GitHub credentials
- [ ] Verify sessions created directly (no parent) still work as before
- [ ] Verify parent lookup failure (e.g., deleted parent) gracefully
falls back
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Ambient Code Bot <bot@ambient-code.local>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 7af078a commit 6b21778
4 files changed
Lines changed: 69 additions & 32 deletions
File tree
- components
- backend/handlers
- manifests
- base/core
- overlays/production
- runners/ambient-runner/ambient_runner/tools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
826 | 826 | | |
827 | 827 | | |
828 | 828 | | |
829 | | - | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
830 | 833 | | |
831 | 834 | | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
839 | | - | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
840 | 843 | | |
841 | | - | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
842 | 849 | | |
843 | 850 | | |
844 | 851 | | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
850 | 867 | | |
851 | 868 | | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
856 | 893 | | |
857 | | - | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | 894 | | |
869 | 895 | | |
870 | 896 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
| |||
148 | 151 | | |
149 | 152 | | |
150 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
151 | 159 | | |
152 | 160 | | |
153 | 161 | | |
| |||
0 commit comments