Prevent session state injection for provider supplied instructions

When the user provides instruction provider, we assume that they will inject the session state parameters if needed. This assumption allows users to return code snippets in the instruction provider without any template replacement.

PiperOrigin-RevId: 759705471
This commit is contained in:
Selcuk Gun
2025-05-16 12:08:24 -07:00
committed by Copybara-Service
parent 5ee17a3268
commit 9e9dfa7472
4 changed files with 74 additions and 23 deletions

View File

@@ -61,6 +61,8 @@ async def test_function_system_instruction():
def build_function_instruction(readonly_context: ReadonlyContext) -> str:
return (
"This is the function agent instruction for invocation:"
" provider template intact { customerId }"
" provider template intact { customer_int }"
f" {readonly_context.invocation_id}."
)
@@ -88,10 +90,12 @@ async def test_function_system_instruction():
pass
assert request.config.system_instruction == (
"This is the function agent instruction for invocation: test_id."
"This is the function agent instruction for invocation:"
" provider template intact { customerId }"
" provider template intact { customer_int }"
" test_id."
)
@pytest.mark.asyncio
async def test_async_function_system_instruction():
async def build_function_instruction(
@@ -99,6 +103,8 @@ async def test_async_function_system_instruction():
) -> str:
return (
"This is the function agent instruction for invocation:"
" provider template intact { customerId }"
" provider template intact { customer_int }"
f" {readonly_context.invocation_id}."
)
@@ -126,7 +132,10 @@ async def test_async_function_system_instruction():
pass
assert request.config.system_instruction == (
"This is the function agent instruction for invocation: test_id."
"This is the function agent instruction for invocation:"
" provider template intact { customerId }"
" provider template intact { customer_int }"
" test_id."
)