Skip to content

/AWS1/IF_BDC=>INVOKEHARNESS()

About InvokeHarness

Operation to invoke a Harness.

Method Signature

METHODS /AWS1/IF_BDC~INVOKEHARNESS
  IMPORTING
    !IV_HARNESSARN TYPE /AWS1/BDCHARNESSARN OPTIONAL
    !IV_RUNTIMESESSIONID TYPE /AWS1/BDCSESSIONID OPTIONAL
    !IV_RUNTIMEUSERID TYPE /AWS1/BDCSTRING OPTIONAL
    !IT_MESSAGES TYPE /AWS1/CL_BDCHARNESSMESSAGE=>TT_HARNESSMESSAGES OPTIONAL
    !IO_MODEL TYPE REF TO /AWS1/CL_BDCHARNESSMODELCONF OPTIONAL
    !IT_SYSTEMPROMPT TYPE /AWS1/CL_BDCHARNSYSCONTBLOCK=>TT_HARNESSSYSTEMPROMPT OPTIONAL
    !IT_TOOLS TYPE /AWS1/CL_BDCHARNESSTOOL=>TT_HARNESSTOOLS OPTIONAL
    !IT_SKILLS TYPE /AWS1/CL_BDCHARNESSSKILL=>TT_HARNESSSKILLS OPTIONAL
    !IT_ALLOWEDTOOLS TYPE /AWS1/CL_BDCHARNESSALWDTOOLS_W=>TT_HARNESSALLOWEDTOOLS OPTIONAL
    !IV_MAXITERATIONS TYPE /AWS1/BDCINTEGER OPTIONAL
    !IV_MAXTOKENS TYPE /AWS1/BDCINTEGER OPTIONAL
    !IV_TIMEOUTSECONDS TYPE /AWS1/BDCINTEGER OPTIONAL
    !IV_ACTORID TYPE /AWS1/BDCSTRING OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_bdcinvokeharnessrsp
  RAISING
    /AWS1/CX_BDCACCESSDENIEDEX
    /AWS1/CX_BDCINTERNALSERVEREX
    /AWS1/CX_BDCRESOURCENOTFOUNDEX
    /AWS1/CX_BDCRUNTIMECLIENTERROR
    /AWS1/CX_BDCTHROTTLINGEX
    /AWS1/CX_BDCVALIDATIONEX
    /AWS1/CX_BDCCLIENTEXC
    /AWS1/CX_BDCSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_harnessarn TYPE /AWS1/BDCHARNESSARN /AWS1/BDCHARNESSARN

The ARN of the harness to invoke.

iv_runtimesessionid TYPE /AWS1/BDCSESSIONID /AWS1/BDCSESSIONID

The session ID for the invocation. Use the same session ID across requests to continue a conversation.

it_messages TYPE /AWS1/CL_BDCHARNESSMESSAGE=>TT_HARNESSMESSAGES TT_HARNESSMESSAGES

The messages to send to the agent.

Optional arguments:

iv_runtimeuserid TYPE /AWS1/BDCSTRING /AWS1/BDCSTRING

An identifier for the end user making the request. This value is passed through to the runtime container.

io_model TYPE REF TO /AWS1/CL_BDCHARNESSMODELCONF /AWS1/CL_BDCHARNESSMODELCONF

The model configuration to use for this invocation. If specified, overrides the harness default.

it_systemprompt TYPE /AWS1/CL_BDCHARNSYSCONTBLOCK=>TT_HARNESSSYSTEMPROMPT TT_HARNESSSYSTEMPROMPT

The system prompt to use for this invocation. If specified, overrides the harness default.

it_tools TYPE /AWS1/CL_BDCHARNESSTOOL=>TT_HARNESSTOOLS TT_HARNESSTOOLS

The tools available to the agent for this invocation. If specified, overrides the harness default.

it_skills TYPE /AWS1/CL_BDCHARNESSSKILL=>TT_HARNESSSKILLS TT_HARNESSSKILLS

The skills available to the agent for this invocation. If specified, overrides the harness default.

it_allowedtools TYPE /AWS1/CL_BDCHARNESSALWDTOOLS_W=>TT_HARNESSALLOWEDTOOLS TT_HARNESSALLOWEDTOOLS

The tools that the agent is allowed to use for this invocation. If specified, overrides the harness default.

iv_maxiterations TYPE /AWS1/BDCINTEGER /AWS1/BDCINTEGER

The maximum number of iterations the agent loop can execute. If specified, overrides the harness default.

iv_maxtokens TYPE /AWS1/BDCINTEGER /AWS1/BDCINTEGER

The maximum number of tokens the agent can generate per iteration. If specified, overrides the harness default.

iv_timeoutseconds TYPE /AWS1/BDCINTEGER /AWS1/BDCINTEGER

The maximum duration in seconds for the agent loop execution. If specified, overrides the harness default.

iv_actorid TYPE /AWS1/BDCSTRING /AWS1/BDCSTRING

The actor ID for memory operations. Overrides the actor ID configured on the harness.

RETURNING

oo_output TYPE REF TO /aws1/cl_bdcinvokeharnessrsp /AWS1/CL_BDCINVOKEHARNESSRSP

Examples

Syntax Example

This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.

DATA(lo_result) = lo_client->invokeharness(
  io_model = new /aws1/cl_bdcharnessmodelconf(
    io_bedrockmodelconfig = new /aws1/cl_bdcharnbdrkmodelcfg(
      io_additionalparams = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
      iv_apiformat = |string|
      iv_maxtokens = 123
      iv_modelid = |string|
      iv_temperature = '0.1'
      iv_topp = '0.1'
    )
    io_geminimodelconfig = new /aws1/cl_bdcharngeminimodelcfg(
      iv_apikeyarn = |string|
      iv_maxtokens = 123
      iv_modelid = |string|
      iv_temperature = '0.1'
      iv_topk = 123
      iv_topp = '0.1'
    )
    io_litellmmodelconfig = new /aws1/cl_bdcharnlitellmmodcfg(
      io_additionalparams = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
      iv_apibase = |string|
      iv_apikeyarn = |string|
      iv_maxtokens = 123
      iv_modelid = |string|
      iv_temperature = '0.1'
      iv_topp = '0.1'
    )
    io_openaimodelconfig = new /aws1/cl_bdcharnopenaimodelcfg(
      io_additionalparams = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
      iv_apiformat = |string|
      iv_apikeyarn = |string|
      iv_maxtokens = 123
      iv_modelid = |string|
      iv_temperature = '0.1'
      iv_topp = '0.1'
    )
  )
  it_allowedtools = VALUE /aws1/cl_bdcharnessalwdtools_w=>tt_harnessallowedtools(
    ( new /aws1/cl_bdcharnessalwdtools_w( |string| ) )
  )
  it_messages = VALUE /aws1/cl_bdcharnessmessage=>tt_harnessmessages(
    (
      new /aws1/cl_bdcharnessmessage(
        it_content = VALUE /aws1/cl_bdcharncontentblock=>tt_harnesscontentblocks(
          (
            new /aws1/cl_bdcharncontentblock(
              io_reasoningcontent = new /aws1/cl_bdcharnreasngcontblk(
                io_reasoningtext = new /aws1/cl_bdcharnreasngtextblk(
                  iv_signature = |string|
                  iv_text = |string|
                )
                iv_redactedcontent = '5347567362473873563239796247513D'
              )
              io_toolresult = new /aws1/cl_bdcharntoolrsltblock(
                it_content = VALUE /aws1/cl_bdcharntoolrscontblk=>tt_harntoolresultcontentblocks(
                  (
                    new /aws1/cl_bdcharntoolrscontblk(
                      io_json = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
                      iv_text = |string|
                    )
                  )
                )
                iv_status = |string|
                iv_tooluseid = |string|
                iv_type = |string|
              )
              io_tooluse = new /aws1/cl_bdcharntooluseblock(
                io_input = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
                iv_name = |string|
                iv_servername = |string|
                iv_tooluseid = |string|
                iv_type = |string|
              )
              iv_text = |string|
            )
          )
        )
        iv_role = |string|
      )
    )
  )
  it_skills = VALUE /aws1/cl_bdcharnessskill=>tt_harnessskills(
    (
      new /aws1/cl_bdcharnessskill(
        io_git = new /aws1/cl_bdcharnskillgitsource(
          io_auth = new /aws1/cl_bdcharnskillgitauth(
            iv_credentialarn = |string|
            iv_username = |string|
          )
          iv_path = |string|
          iv_url = |string|
        )
        io_s3 = new /aws1/cl_bdcharnskills3source( |string| )
        iv_path = |string|
      )
    )
  )
  it_systemprompt = VALUE /aws1/cl_bdcharnsyscontblock=>tt_harnesssystemprompt(
    ( new /aws1/cl_bdcharnsyscontblock( |string| ) )
  )
  it_tools = VALUE /aws1/cl_bdcharnesstool=>tt_harnesstools(
    (
      new /aws1/cl_bdcharnesstool(
        io_config = new /aws1/cl_bdcharnesstoolconf(
          io_agentcorebrowser = new /aws1/cl_bdcharnagentcorebrcfg( |string| )
          io_agentcorecodeinterpreter = new /aws1/cl_bdcharnagcorecodein00( |string| )
          io_agentcoregateway = new /aws1/cl_bdcharnagentcoregwcfg(
            io_outboundauth = new /aws1/cl_bdcharngwoutbndauth(
              io_awsiam = new /aws1/cl_bdcunit( )
              io_none = new /aws1/cl_bdcunit( )
              io_oauth = new /aws1/cl_bdcoauthcredprovider(
                it_customparameters = VALUE /aws1/cl_bdcoauthcustparams_w=>tt_oauthcustomparameters(
                  (
                    VALUE /aws1/cl_bdcoauthcustparams_w=>ts_oauthcustomparams_maprow(
                      key = |string|
                      value = new /aws1/cl_bdcoauthcustparams_w( |string| )
                    )
                  )
                )
                it_scopes = VALUE /aws1/cl_bdcoauthscopes_w=>tt_oauthscopes(
                  ( new /aws1/cl_bdcoauthscopes_w( |string| ) )
                )
                iv_defaultreturnurl = |string|
                iv_granttype = |string|
                iv_providerarn = |string|
              )
            )
            iv_gatewayarn = |string|
          )
          io_inlinefunction = new /aws1/cl_bdcharninlfuncconfig(
            io_inputschema = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
            iv_description = |string|
          )
          io_remotemcp = new /aws1/cl_bdcharnrmtmcpconfig(
            it_headers = VALUE /aws1/cl_bdchttpheadersmap_w=>tt_httpheadersmap(
              (
                VALUE /aws1/cl_bdchttpheadersmap_w=>ts_httpheadersmap_maprow(
                  key = |string|
                  value = new /aws1/cl_bdchttpheadersmap_w( |string| )
                )
              )
            )
            iv_url = |string|
          )
        )
        iv_name = |string|
        iv_type = |string|
      )
    )
  )
  iv_actorid = |string|
  iv_harnessarn = |string|
  iv_maxiterations = 123
  iv_maxtokens = 123
  iv_runtimesessionid = |string|
  iv_runtimeuserid = |string|
  iv_timeoutseconds = 123
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  TRY.
    WHILE lo_result->get_stream( )->/aws1/if_rt_stream_reader~data_available( ) = ABAP_TRUE.
      lo_event = lo_result->get_stream( )->READ( ).
      IF lo_event->get_messagestart( ) IS NOT INITIAL.
        " process this kind of event
      ELSEIF lo_event->get_contentblockstart( ) IS NOT INITIAL.
        " process this kind of event
      ELSEIF lo_event->get_contentblockdelta( ) IS NOT INITIAL.
        " process this kind of event
      ELSEIF lo_event->get_contentblockstop( ) IS NOT INITIAL.
        " process this kind of event
      ELSEIF lo_event->get_messagestop( ) IS NOT INITIAL.
        " process this kind of event
      ELSEIF lo_event->get_metadata( ) IS NOT INITIAL.
        " process this kind of event
      ENDIF.
    ENDWHILE.
  CATCH /aws1/cx_bdcinternalserverex.
    " handle error in stream
  CATCH /aws1/cx_bdcvalidationex.
    " handle error in stream
  CATCH /aws1/cx_bdcruntimeclienterror.
    " handle error in stream
  ENDTRY.
ENDIF.