Skip to content

fix(logging): include system prompt in debug logs in case of response… #1154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added ,
Empty file.
4 changes: 3 additions & 1 deletion src/agents/models/openai_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ async def _fetch_response(
else NOT_GIVEN
)

system_instructions = self._non_null_or_not_given(system_instructions)
tool_choice = Converter.convert_tool_choice(model_settings.tool_choice)
converted_tools = Converter.convert_tools(tools, handoffs)
response_format = Converter.get_response_format(output_schema)
Expand All @@ -255,6 +256,7 @@ async def _fetch_response(
else:
logger.debug(
f"Calling LLM {self.model} with input:\n"
f"System instructions: {system_instructions}\n"
f"{json.dumps(list_input, indent=2, ensure_ascii=False)}\n"
f"Tools:\n{json.dumps(converted_tools.tools, indent=2, ensure_ascii=False)}\n"
f"Stream: {stream}\n"
Expand All @@ -265,7 +267,7 @@ async def _fetch_response(

return await self._client.responses.create(
previous_response_id=self._non_null_or_not_given(previous_response_id),
instructions=self._non_null_or_not_given(system_instructions),
instructions=system_instructions,
model=self.model,
input=list_input,
include=include,
Expand Down