test_case_id: "embed_status_update_with_tool_call_001"
description: "Tests that a «status_update:...» embed is correctly processed when it is immediately followed by a peer tool_call in the LLM response."
tags: ["all","common","embeds"]
skip_intermediate_events: true


gateway_input:
  target_agent_name: "TestAgent"
  user_identity: "embed_tester@example.com"
  prompt:
    parts:
      - text: "Delegate a task to Peer B and give a status update."

llm_interactions:
  - static_response:
      choices:
        - message:
            role: "assistant"
            content: "«status_update:Delegating the task to TestPeerAgentB...»"
            tool_calls:
              - id: "call_peer_b_for_status_test"
                type: "function"
                function:
                  name: "peer_TestPeerAgentB"
                  arguments: '{"task_description": "Please provide a status report."}'
    expected_request:
      messages_contain:
        - role: "user"
          content_contains: "Delegate a task to Peer B"
      tools_present:
        - "peer_TestPeerAgentB"

  - static_response:
      choices:
        - message:
            role: "assistant"
            content: "TestPeerAgentB reporting: All systems are nominal."
    expected_request:
      messages_contain:
        - role: "user"
          content_contains: "Please provide a status report."

  - static_response:
      choices:
        - message:
            role: "assistant"
            content: "The peer agent has responded. Here is their report: TestPeerAgentB reporting: All systems are nominal."
    expected_request:
      expected_tool_responses_in_llm_messages:
        - tool_call_id_matches_prior_request_index: 0 # Matches the tool call from the first LLM interaction
          response_contains: "All systems are nominal."

expected_gateway_output:
  - type: "status_update"
    event_purpose: "embedded_status_update"
    content_parts:
      - type: "text"
        text_exact: "Delegating the task to TestPeerAgentB..."
    final_flag: false

  - type: "status_update"
    event_purpose: "tool_invocation_start"
    expected_tool_name: "peer_TestPeerAgentB"
    expected_tool_args_contain:
      task_description: "Please provide a status report."

  - type: "final_response"
    content_parts:
      - type: "text"
        text_contains: ""
    task_state: "completed"

expected_artifacts: []
