Skip to content

When the agent performs a handoff, can I append the new user input to the end of the handoff history log? #408

Closed as not planned
@cuisiteht

Description

@cuisiteht

Please read this first

  • Have you read the docs?Agents SDK docs
  • Have you searched for related issues? Others may have had similar requesrs

Question

Describe your question. Provide details if available.

when the pipeline turns to the second agent,i got the next trace log:

[
  {
    "content": "you are a expert of tce, you can help me to fix the tce problem, \n    you must use the sop to continue fixing problem: \u6267\u884c ${TOOL:tce webshell}  \u5de5\u5177,\u5e76\u8fd0\u884c `echo $TCE_PRIMARY_PORT` \u547d\u4ee4,\u68c0\u67e5\u7aef\u53e3\u662f\u5426\u88ab\u76d1\u542c\n    1.  \u82e5\u88ab\u76d1\u542c,\u6216\u6ca1\u76d1\u542c\u4e5f\u6ca1\u5f00 rpc \u5165\u6d41\u91cf\u4ee3\u7406,\u5219\u4e0d\u662f\u7aef\u53e3\u95ee\u9898,\u6d41\u7a0b\u7ed3\u675f\n    2.  \u82e5\u6ca1\u88ab\u76d1\u542c,\u4e14\u6ca1\u5f00 rpc \u5165\u6d41\u91cf\u4ee3\u7406\uff0c\u662f\u7aef\u53e3\u95ee\u9898\u3002.",
    "role": "system"
  },
  {
    "role": "user",
    "content": "\u5e2e\u6211\u68c0\u67e5\u5de5\u5355id\u4e3aht-123456\u7684tce\u5de5\u5355\u7684\u6545\u969c\u539f\u56e0"
  },
  {
    "role": "user",
    "content": "you are a expert of tce, you can help me to fix the tce problem, \n    you must use the sop to continue fixing problem: \u6267\u884c ${TOOL:tce webshell}  \u5de5\u5177,\u5e76\u8fd0\u884c `echo $TCE_PRIMARY_PORT` \u547d\u4ee4,\u68c0\u67e5\u7aef\u53e3\u662f\u5426\u88ab\u76d1\u542c\n    1.  \u82e5\u88ab\u76d1\u542c,\u6216\u6ca1\u76d1\u542c\u4e5f\u6ca1\u5f00 rpc \u5165\u6d41\u91cf\u4ee3\u7406,\u5219\u4e0d\u662f\u7aef\u53e3\u95ee\u9898,\u6d41\u7a0b\u7ed3\u675f\n    2.  \u82e5\u6ca1\u88ab\u76d1\u542c,\u4e14\u6ca1\u5f00 rpc \u5165\u6d41\u91cf\u4ee3\u7406\uff0c\u662f\u7aef\u53e3\u95ee\u9898\u3002."
  },
  {
    "role": "assistant",
    "content": "\u5f53\u7136,\u6211\u5f88\u4e50\u610f\u5e2e\u60a8\u68c0\u67e5\u5de5\u5355ID\u4e3aht-123456\u7684TCE\u5de5\u5355\u7684\u6545\u969c\u539f\u56e0\u3002\u8ba9\u6211\u4eec\u6309\u7167SOP(\u6807\u51c6\u64cd\u4f5c\u7a0b\u5e8f)\u6765\u9010\u6b65\u8fdb\u884c\u68c0\u67e5\u3002\n\n\u9996\u5148,\u8ba9\u6211\u4eec\u83b7\u53d6TCE\u5de5\u5355\u7684\u914d\u7f6e\u4fe1\u606f:"
  },
  {
    "role": "assistant",
    "content": "\u6839\u636e\u83b7\u53d6\u7684\u914d\u7f6e\u4fe1\u606f,\u6211\u4eec\u53ef\u4ee5\u770b\u5230:\n- PSM: akasaka.hello.grpc\n- Pod\u540d\u79f0: dp-30db299c79-6c7696c6c7-rm7kl\n- TCE\u73af\u5883: ppe_akasaka_test\n- \u5931\u8d25\u8be6\u60c5: \u9636\u6bb52\u5931\u8d25,\u5931\u8d25\u4ee3\u7801\u4e3a\"port not open\"\n- \u7f51\u7edc\u6a21\u5f0f: bridge\n\n\u63a5\u4e0b\u6765,\u8ba9\u6211\u4eec\u6267\u884c\u7b2c\u4e8c\u6b65,\u68c0\u67e5\u670d\u52a1\u76d1\u542c\u7aef\u53e3:"
  },
  {
    "role": "assistant",
    "content": "\u4ece\u8f93\u51fa\u7ed3\u679c\u53ef\u4ee5\u770b\u5230,\u6709\u51e0\u4e2a\u8fdb\u7a0b\u6b63\u5728\u76d1\u542c\u7aef\u53e3\u3002\u8fd9\u8868\u660e\u670d\u52a1\u8fdb\u7a0b\u786e\u5b9e\u5728\u8fd0\u884c,\u5e76\u4e14\u6709\u7aef\u53e3\u5728\u76d1\u542c\u3002\n\n\u6839\u636eSOP\u7684\u7b2c\u4e09\u6b65,\u6211\u4eec\u9700\u8981\u5206\u6790TCE\u4e0a\u4e0b\u6587\u5e76\u786e\u5b9a\u7f51\u7edc\u6a21\u5f0f\u3002\u4ece\u4e4b\u524d\u83b7\u53d6\u7684\u914d\u7f6e\u4fe1\u606f\u4e2d,\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u7f51\u7edc\u6a21\u5f0f\u662f\"bridge\"\u3002\n\n\u7531\u4e8e\u6211\u4eec\u5df2\u7ecf\u5b8c\u6210\u4e86SOP\u4e2d\u7684\u6240\u6709\u6b65\u9aa4,\u73b0\u5728\u6211\u4eec\u9700\u8981\u5c06\u95ee\u9898\u8f6c\u4ea4\u7ed9bridge_agent\u6765\u7ee7\u7eed\u5904\u7406,\u56e0\u4e3a\u7f51\u7edc\u6a21\u5f0f\u662fbridge\u3002"
  }
]
Tools:
[
  {
    "type": "function",
    "function": {
      "name": "tce_webshell",
      "description": "run the command in the tce webshell",
      "parameters": {
        "properties": {
          "command": {
            "title": "Command",
            "type": "string"
          },
          "pod_name": {
            "title": "Pod Name",
            "type": "string"
          },
          "tce_env": {
            "title": "Tce Env",
            "type": "string"
          },
          "psm": {
            "title": "Psm",
            "type": "string"
          }
        },
        "required": [
          "command",
          "pod_name",
          "tce_env",
          "psm"
        ],
        "title": "tce_webshell_args",
        "type": "object",
        "additionalProperties": false
      }
    }
  }
]

by using the input filters

def sop_handoff_message_filter(handoff_message_data: HandoffInputData, user_input: str) -> HandoffInputData:
    # First, we'll remove any tool-related messages from the message history
    # handoff_message_data = handoff_filters.remove_all_tools(handoff_message_data)

    # Second, we'll also remove the first two items from the history, just for demonstration
    history = (
        tuple(handoff_message_data.input_history + ({"role": "user", "content": user_input},))
        if isinstance(handoff_message_data.input_history, tuple)
        else handoff_message_data.input_history
    )

    print(history)

    return HandoffInputData(
        input_history=history,
        pre_handoff_items=tuple(handoff_message_data.pre_handoff_items),
        new_items=tuple(handoff_message_data.new_items),
    )

now, can i put the user input to the latest of my history messages?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about using the SDKstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions