Skip to content

Python: [Bug]: Final output is empty after successful tool execution in declarative agent run #5726

@hapiiiiGit

Description

@hapiiiiGit

Description

Description

I encountered an issue where the declarative agent successfully generated and executed the expected Python solution via python_executor, but the final assistant response was empty, resulting in an empty final_output.

The the tool execution is succeeded. However, after the tool result was returned to the model, the final chat_output contained an assistant message with empty contents, and the recorded final_output was "". :contentReference[oaicite:0]{index=0}

Environment / Config

  • Agent config:
instructions: |
  You are a Python coding assistant. Your task is to complete the following Python code from the HumanEval benchmark.
  Use tools when they help, and give concise, evidence-aware answers.
  Note:
    1. Output only final valid Python code. The final answer must be executable Python code.

model:
  connection:
    kind: key
  options:
    temperature: 0.0
    maxOutputTokens: 512
    allowMultipleToolCalls: false
    chatToolMode: auto
tools:
  - kind: function
    name: python_executor
    description: Execute Python code in a short-lived subprocess.
    bindings:
      - name: python_executor

What Happened

  • The model first generated a valid implementation and called python_executor
  • The tool execution succeeded:
{
  "ok": true,
  "stdout": "1.0\n",
  "stderr": "",
  "returncode": 0,
  "timed_out": false
}
  • After that, the model was called again with the tool result. The final response was:
{
  "role": "assistant",
  "contents": []
}
  • The run ended with:
"finish_reason": "stop",
"final_output": ""

Expected Behavior

After successful tool execution, the agent should return the final valid Python code.

Code Sample

Error Messages / Stack Traces

Package Versions

agent-framework 1.3.0, agent-framework-declarative 1.0.0b260507

Python Version

Python 3.14.4

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions