@@ -75,41 +75,45 @@ def test_canonical_model_inherit():
75
75
assert sub_agent .canonical_model == parent_agent .canonical_model
76
76
77
77
78
- def test_canonical_instruction_str ():
78
+ async def test_canonical_instruction_str ():
79
79
agent = LlmAgent (name = 'test_agent' , instruction = 'instruction' )
80
80
ctx = _create_readonly_context (agent )
81
81
82
- assert agent .canonical_instruction (ctx ) == 'instruction'
82
+ canonical_instruction = await agent .canonical_instruction (ctx )
83
+ assert canonical_instruction == 'instruction'
83
84
84
85
85
- def test_canonical_instruction ():
86
+ async def test_canonical_instruction ():
86
87
def _instruction_provider (ctx : ReadonlyContext ) -> str :
87
88
return f'instruction: { ctx .state ["state_var" ]} '
88
89
89
90
agent = LlmAgent (name = 'test_agent' , instruction = _instruction_provider )
90
91
ctx = _create_readonly_context (agent , state = {'state_var' : 'state_value' })
91
92
92
- assert agent .canonical_instruction (ctx ) == 'instruction: state_value'
93
+ canonical_instruction = await agent .canonical_instruction (ctx )
94
+ assert canonical_instruction == 'instruction: state_value'
93
95
94
96
95
- def test_async_canonical_instruction ():
97
+ async def test_async_canonical_instruction ():
96
98
async def _instruction_provider (ctx : ReadonlyContext ) -> str :
97
99
return f'instruction: { ctx .state ["state_var" ]} '
98
100
99
101
agent = LlmAgent (name = 'test_agent' , instruction = _instruction_provider )
100
102
ctx = _create_readonly_context (agent , state = {'state_var' : 'state_value' })
101
103
102
- assert agent .canonical_instruction (ctx ) == 'instruction: state_value'
104
+ canonical_instruction = await agent .canonical_instruction (ctx )
105
+ assert canonical_instruction == 'instruction: state_value'
103
106
104
107
105
- def test_canonical_global_instruction_str ():
108
+ async def test_canonical_global_instruction_str ():
106
109
agent = LlmAgent (name = 'test_agent' , global_instruction = 'global instruction' )
107
110
ctx = _create_readonly_context (agent )
108
111
109
- assert agent .canonical_global_instruction (ctx ) == 'global instruction'
112
+ canonical_global_instruction = await agent .canonical_global_instruction (ctx )
113
+ assert canonical_global_instruction == 'global instruction'
110
114
111
115
112
- def test_canonical_global_instruction ():
116
+ async def test_canonical_global_instruction ():
113
117
def _global_instruction_provider (ctx : ReadonlyContext ) -> str :
114
118
return f'global instruction: { ctx .state ["state_var" ]} '
115
119
@@ -118,13 +122,11 @@ def _global_instruction_provider(ctx: ReadonlyContext) -> str:
118
122
)
119
123
ctx = _create_readonly_context (agent , state = {'state_var' : 'state_value' })
120
124
121
- assert (
122
- agent .canonical_global_instruction (ctx )
123
- == 'global instruction: state_value'
124
- )
125
+ canonical_global_instruction = await agent .canonical_global_instruction (ctx )
126
+ assert canonical_global_instruction == 'global instruction: state_value'
125
127
126
128
127
- def test_async_canonical_global_instruction ():
129
+ async def test_async_canonical_global_instruction ():
128
130
async def _global_instruction_provider (ctx : ReadonlyContext ) -> str :
129
131
return f'global instruction: { ctx .state ["state_var" ]} '
130
132
@@ -133,10 +135,8 @@ async def _global_instruction_provider(ctx: ReadonlyContext) -> str:
133
135
)
134
136
ctx = _create_readonly_context (agent , state = {'state_var' : 'state_value' })
135
137
136
- assert (
137
- agent .canonical_global_instruction (ctx )
138
- == 'global instruction: state_value'
139
- )
138
+ canonical_global_instruction = await agent .canonical_global_instruction (ctx )
139
+ assert canonical_global_instruction == 'global instruction: state_value'
140
140
141
141
142
142
def test_output_schema_will_disable_transfer (caplog : pytest .LogCaptureFixture ):
0 commit comments