@@ -682,6 +682,12 @@ async def _get_conversation_messages_path(
682682 async def _build_input_text (self , state : Any , arguments : dict [str , Any ], messages_expr : Any ) -> str :
683683 """Build input text from arguments and messages.
684684
685+ ``input.arguments`` are formatted as ``key: value`` lines (same shape as the
686+ multi-value ``Workflow.Inputs`` fallback) and included in the text sent to
687+ ``agent.run()``. Python's agent ``run()`` has no separate structured-inputs
688+ channel, so arguments must be folded into this text rather than discarded
689+ (#7902).
690+
685691 Args:
686692 state: Workflow state for expression evaluation
687693 arguments: Input arguments to evaluate
@@ -690,55 +696,61 @@ async def _build_input_text(self, state: Any, arguments: dict[str, Any], message
690696 Returns:
691697 Input text for the agent
692698 """
693- # Evaluate arguments
694699 evaluated_args : dict [str , Any ] = {}
695700 for key , value in arguments .items ():
696701 evaluated_args [key ] = state .eval_if_expression (value )
702+ args_text = "\n " .join (f"{ k } : { v } " for k , v in evaluated_args .items ()) if evaluated_args else ""
697703
698- # Evaluate messages/input
704+ messages_text = ""
699705 if messages_expr :
700706 evaluated_input : Any = state .eval_if_expression (messages_expr )
701707 if isinstance (evaluated_input , str ):
702- return evaluated_input
703- if isinstance (evaluated_input , list ) and evaluated_input :
708+ messages_text = evaluated_input
709+ elif isinstance (evaluated_input , list ) and evaluated_input :
704710 # Extract text from last message
705711 last : Any = evaluated_input [- 1 ] # type: ignore
706712 if isinstance (last , str ):
707- return last
708- if isinstance (last , dict ):
713+ messages_text = last
714+ elif isinstance (last , dict ):
709715 last_dict = cast (dict [str , Any ], last )
710716 content_val : Any = last_dict .get ("content" , last_dict .get ("text" , "" ))
711- return str (content_val ) if content_val else ""
712- if last is not None and hasattr (last , "text" ): # type: ignore
713- return str (getattr (last , "text" , "" )) # type: ignore
714- if evaluated_input :
715- return str (cast (Any , evaluated_input ))
716- return ""
717-
718- # Fallback chain for implicit input (like .NET conversationId pattern):
719- # 1. Local.input / Local.userInput (explicit turn state)
720- # 2. System.LastMessage.Text (previous agent's response)
721- # 3. Workflow.Inputs (first agent gets workflow inputs)
722- input_text : str = str (state .get ("Local.input" ) or state .get ("Local.userInput" ) or "" )
723- if not input_text :
724- # Try System.LastMessage.Text (used by external loop and agent chaining)
725- last_message : Any = state .get ("System.LastMessage" )
726- if isinstance (last_message , dict ):
727- last_msg_dict = cast (dict [str , Any ], last_message )
728- text_val : Any = last_msg_dict .get ("Text" , "" )
729- input_text = str (text_val ) if text_val else ""
730- if not input_text :
731- # Fall back to workflow inputs (for first agent in chain)
732- inputs : Any = state .get ("Workflow.Inputs" )
733- if isinstance (inputs , dict ):
734- inputs_dict = cast (dict [str , Any ], inputs )
735- # If single input, use its value directly
736- if len (inputs_dict ) == 1 :
737- input_text = str (next (iter (inputs_dict .values ())))
738- else :
739- # Multiple inputs - format as key: value pairs
740- input_text = "\n " .join (f"{ k } : { v } " for k , v in inputs_dict .items ())
741- return input_text if input_text else ""
717+ messages_text = str (content_val ) if content_val else ""
718+ elif last is not None and hasattr (last , "text" ): # type: ignore
719+ messages_text = str (getattr (last , "text" , "" )) # type: ignore
720+ elif evaluated_input :
721+ messages_text = str (cast (Any , evaluated_input ))
722+ elif not evaluated_args :
723+ # Fallback chain for implicit input (like .NET conversationId pattern):
724+ # Only when neither explicit messages nor explicit arguments are present.
725+ # Otherwise arguments-only actions (e.g. customer-support TicketingAgent)
726+ # would append System.LastMessage (prior agent's response) or
727+ # Workflow.Inputs to their structured fields in chained workflows.
728+ # 1. Local.input / Local.userInput (explicit turn state)
729+ # 2. System.LastMessage.Text (previous agent's response)
730+ # 3. Workflow.Inputs (first agent gets workflow inputs)
731+ messages_text = str (state .get ("Local.input" ) or state .get ("Local.userInput" ) or "" )
732+ if not messages_text :
733+ # Try System.LastMessage.Text (used by external loop and agent chaining)
734+ last_message : Any = state .get ("System.LastMessage" )
735+ if isinstance (last_message , dict ):
736+ last_msg_dict = cast (dict [str , Any ], last_message )
737+ text_val : Any = last_msg_dict .get ("Text" , "" )
738+ messages_text = str (text_val ) if text_val else ""
739+ if not messages_text :
740+ # Fall back to workflow inputs (for first agent in chain)
741+ inputs : Any = state .get ("Workflow.Inputs" )
742+ if isinstance (inputs , dict ):
743+ inputs_dict = cast (dict [str , Any ], inputs )
744+ # If single input, use its value directly
745+ if len (inputs_dict ) == 1 :
746+ messages_text = str (next (iter (inputs_dict .values ())))
747+ else :
748+ # Multiple inputs - format as key: value pairs
749+ messages_text = "\n " .join (f"{ k } : { v } " for k , v in inputs_dict .items ())
750+
751+ if args_text and messages_text :
752+ return f"{ args_text } \n { messages_text } "
753+ return args_text or messages_text or ""
742754
743755 def _get_agent (self , agent_name : str , ctx : WorkflowContext [Any , Any ]) -> Any :
744756 """Get agent from registry (sync helper for response handler)."""
0 commit comments