Commit 343fedc
authored
fix(invoke): auto-generate session ID for bearer-token invocations (#953)
Closes #840
When invoking an agent with a bearer token (OAuth/CUSTOM_JWT) and no
session ID, `AgentCoreMemoryConfig` raised a Pydantic validation error
because `session_id=None` is rejected. Unlike SigV4 callers, bearer-token
callers do not get a server-side auto-generated runtime session ID.
Two-layer fix:
1. CLI synthesizes a UUID in `invoke` action when `--bearer-token` is set
and `--session-id` is missing, using the existing `generateSessionId`
helper. Covers both explicit `--bearer-token` and the CUSTOM_JWT
auto-fetch path.
2. Strands memory session templates (http, agui, a2a) synthesize a UUID
when `session_id` is falsy before constructing AgentCoreMemoryConfig.
Protects direct runtime callers (curl, custom apps) who forget the
`X-Amzn-Bedrock-AgentCore-Runtime-Session-Id` header.
Snapshot tests updated.1 parent f8dc490 commit 343fedc
5 files changed
Lines changed: 45 additions & 6 deletions
File tree
- src
- assets
- __tests__/__snapshots__
- python
- a2a/strands/capabilities/memory
- agui/strands/capabilities/memory
- http/strands/capabilities/memory
- cli/commands/invoke
Lines changed: 18 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1889 | 1889 | | |
1890 | 1890 | | |
1891 | 1891 | | |
| 1892 | + | |
1892 | 1893 | | |
1893 | 1894 | | |
1894 | 1895 | | |
| |||
1897 | 1898 | | |
1898 | 1899 | | |
1899 | 1900 | | |
1900 | | - | |
| 1901 | + | |
1901 | 1902 | | |
1902 | 1903 | | |
1903 | 1904 | | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
1904 | 1909 | | |
1905 | 1910 | | |
1906 | 1911 | | |
| |||
2724 | 2729 | | |
2725 | 2730 | | |
2726 | 2731 | | |
| 2732 | + | |
2727 | 2733 | | |
2728 | 2734 | | |
2729 | 2735 | | |
| |||
2732 | 2738 | | |
2733 | 2739 | | |
2734 | 2740 | | |
2735 | | - | |
| 2741 | + | |
2736 | 2742 | | |
2737 | 2743 | | |
2738 | 2744 | | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
2739 | 2749 | | |
2740 | 2750 | | |
2741 | 2751 | | |
| |||
4993 | 5003 | | |
4994 | 5004 | | |
4995 | 5005 | | |
| 5006 | + | |
4996 | 5007 | | |
4997 | 5008 | | |
4998 | 5009 | | |
| |||
5001 | 5012 | | |
5002 | 5013 | | |
5003 | 5014 | | |
5004 | | - | |
| 5015 | + | |
5005 | 5016 | | |
5006 | 5017 | | |
5007 | 5018 | | |
| 5019 | + | |
| 5020 | + | |
| 5021 | + | |
| 5022 | + | |
5008 | 5023 | | |
5009 | 5024 | | |
5010 | 5025 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
117 | 126 | | |
118 | 127 | | |
119 | 128 | | |
| |||
0 commit comments