Skip to content

Commit 20dbb08

Browse files
committed
Improve wrap_error()
1 parent 0b4b737 commit 20dbb08

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

coagent/agents/chat_agent.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,16 @@ async def run(
167167
# but excepts possible `self`) are keyword arguments.
168168
sig = inspect.signature(func)
169169
for name, param in sig.parameters.items():
170-
if name not in kwargs and isinstance(param.default, FieldInfo):
171-
default = param.default.default
172-
if default is PydanticUndefined:
173-
raise ValueError(f"Missing required argument {name!r}")
174-
else:
170+
if name not in kwargs:
171+
if isinstance(param.default, FieldInfo):
172+
# The default value is a Pydantic Field.
173+
default = param.default.default
174+
if default is PydanticUndefined:
175+
raise ValueError(f"Missing required argument {name!r}")
175176
kwargs[name] = default
177+
elif param.default != inspect.Parameter.empty:
178+
# Normal default value.
179+
kwargs[name] = param.default
176180

177181
result = func(*args, **kwargs)
178182
if is_async_iterator(result):

0 commit comments

Comments
 (0)