Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Python: [Bug]: UserMessage/AgentMessage return different shapes from WorkflowState and DeclarativeWorkflowState

Abierto
#9,041 1 comentario 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@eavanvalkenburg ya está trabajando en esto.

Desde el 5/10/2026.

  • #9101 de @he-yufeng — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Compare the two evaluation paths in _powerfx_functions.py and _declarative_base.py, then trace how each MessageText implementation reads messages. The issue leaves the canonical shape to a maintainer, so get that direction before changing code. Done means both evaluation paths produce the agreed shape and both MessageText implementations read it consistently.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

python vnext
Language

Python

What happened?

The same declarative formula produces two different message shapes depending on which public state class evaluates it:

from agent_framework_declarative._workflows._state import WorkflowState

WorkflowState().eval('=UserMessage("hi")')
# {'role': 'user', 'content': 'hi'}

WorkflowState (standalone) routes to _powerfx_functions.user_message, which returns a flat content key (python/packages/declarative/agent_framework_declarative/_workflows/_powerfx_functions.py:107, same for assistant_message / agent_message / system_message).

DeclarativeWorkflowState (what factory-created workflows use) routes to _eval_custom_function, which returns a flat text key for UserMessage / AgentMessage:

return {"role": "user", "text": str(text) if text else ""}  # _declarative_base.py:755

The two MessageText implementations each read only their own side's shape, so a message that crosses paths silently extracts nothing:

  • _declarative_base._eval_and_replace_message_text reads text first, then a contents list; it never reads content (_declarative_base.py:858-885). A content-shaped message yields "".
  • _powerfx_functions.message_text reads content, so on a text-shaped message it returns "":
from agent_framework_declarative._workflows._powerfx_functions import message_text

message_text([{"role": "user", "text": "hi"}])     # ''
message_text([{"role": "user", "content": "hi"}])  # 'hi'

The agent-side consumer is more tolerant (_executors_agents.py:716 reads content then text), which papers over the split for agent invocations but not for MessageText.

For reference, the .NET canonical shape is a structured record (dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/Functions/MessageFunction.cs): {__type__, Role, Content: [{Type: "Text", Value: ...}]}, i.e. neither flat Python shape. Feeding that shape to the fallback message_text today stringifies the content table:

message_text([{"role": "user", "content": [{"type": "text", "value": "hi"}]}])
# "[{'type': 'text', 'value': 'hi'}]"

Verified on current main (e9857bd75a21843803431a2e7dfa41ee9b017ac7) with agent-framework-declarative installed from source; the .NET shape was read from the in-repo dotnet sources.

What should happen?

One canonical message shape for the Python package, with both eval paths producing it and both MessageText implementations reading it. Which key wins (flat text, flat content, or the structured .NET-style content list) looks like a maintainer call; happy to send the PR once there is a direction.

Lenguaje dominante
Python
Estrellas
13.9k
Forks
2.4k
Merge medio
1 d 18 h
PR fusionados (30 d)
443

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/agent-framework

Todos los issues de microsoft/agent-framework

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.