Commit 59970b6
perf: remove state injection when instruction has no placeholders
inject_session_state runs an async regex substitution over the
instruction on every LLM call to fill {state} and {artifact.x}
placeholders. The pattern ({+[^{}]*}+) requires a '{', so a template
that contains no '{' can never match and is returned unchanged.
Static instructions with no placeholders are the common case, so
short-circuit before the scan and skip the regex pass and the
per-call async substitution setup. Behavior is unchanged.
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 9405350881 parent e470548 commit 59970b6
2 files changed
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
75 | 88 | | |
76 | 89 | | |
77 | 90 | | |
| |||
0 commit comments