@@ -418,7 +418,8 @@ async def run(
418418 if run_config is None :
419419 run_config = RunConfig ()
420420
421- # Prepare input with session if enabled
421+ # Keep original user input separate from session-prepared input
422+ original_user_input = input
422423 prepared_input = await self ._prepare_input_with_session (
423424 input , session , run_config .session_input_callback
424425 )
@@ -447,8 +448,8 @@ async def run(
447448 current_agent = starting_agent
448449 should_run_agent_start_hooks = True
449450
450- # save the original input to the session if enabled
451- await self ._save_result_to_session (session , original_input , [])
451+ # save only the new user input to the session, not the combined history
452+ await self ._save_result_to_session (session , original_user_input , [])
452453
453454 try :
454455 while True :
@@ -1490,13 +1491,14 @@ async def _prepare_input_with_session(
14901491 if session is None :
14911492 return input
14921493
1493- # If the user doesn't explicitly specify a mode, raise an error
1494+ # If the user doesn't specify an input callback and pass a list as input
14941495 if isinstance (input , list ) and not session_input_callback :
14951496 raise UserError (
1496- "You must specify the `session_input_callback` in the `RunConfig`. "
1497- "Otherwise, when using session memory, provide only a string input to append to "
1498- "the conversation, or use session=None and provide a list to manually manage "
1499- "conversation history."
1497+ "When using session memory, list inputs require a "
1498+ "`RunConfig.session_input_callback` to define how they should be merged "
1499+ "with the conversation history. If you don't want to use a callback, "
1500+ "provide your input as a string instead, or disable session memory "
1501+ "(session=None) and pass a list to manage the history manually."
15001502 )
15011503
15021504 # Get previous conversation history
0 commit comments