Skip to content

Conversation

@Jonas-Isr
Copy link
Member

@Jonas-Isr Jonas-Isr commented Nov 19, 2025

Context

AI/ai-sdk-java-backlog#269

This PR introduces convenience for specifying additional metadata parameters for grounding calls through orchestration. It also includes appropriate unit and e2e tests.

Note: The use case for this feature according to the help.sap.com documentation of it is to receive additional information, i.e., the metadata of used chunks/documents, when using grounding via orchestration.

Feature scope:

  • add convenience
  • add tests
    • unit test
    • extend e2e test

Definition of Done

@Jonas-Isr Jonas-Isr self-assigned this Nov 19, 2025
@Jonas-Isr Jonas-Isr added the please-review Request to review a pull-request label Nov 19, 2025
}

@Test
void testGroundingWithConvenience() throws IOException {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this test since the only grounding unit test I saw was only testing low-level code (not our convenience).

Comment on lines +103 to +106
.filters(filters)
.metadataParams(metadataParams);

// metadata_params field is not allowed for data repository type: `help.sap.com`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(minor)

This looks a bit counter intuitive. Instead of setting metadataParams first and then conditionally removing it, we should just conditionally set it.

Suggested change
.filters(filters)
.metadataParams(metadataParams);
// metadata_params field is not allowed for data repository type: `help.sap.com`
.filters(filters);
// metadata_params field is not allowed for data repository type: `help.sap.com`
val hasHepSapCom =
filters.contains(
DocumentGroundingFilter.create().dataRepositoryType(DataRepositoryType.HELP_SAP_COM));
if (!hasHepSapCom) {
groundingConfigConfig.setMetadataParams(metadataParams);
}

Then, you can also set the default value of field metadataParams to null

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach unfortunately does not work since if you do not set metadata params explicitly, the generated code will use an empty list which already leads to an error form grounding service when using help.sap.com.

I changed the default value of the field to null but unfortunately do not see how to improve the code snippet you marked (I agree that it doesn't look ideal).

Copy link
Member

@rpanackal rpanackal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Question)

Correct me if I am wrong.

So the convenience only for passing the metadata_params in request but not inferring its result out of response, right?

@Jonas-Isr
Copy link
Member Author

So the convenience only for passing the metadata_params in request but not inferring its result out of response, right?

Yes, exactly. And the only way to get the metadata out of the response is by parsing the string of grounding_result. This is (as far as I understand) mainly to give the LLM access to the metadata when answering.

@Jonas-Isr Jonas-Isr merged commit 7760819 into main Nov 20, 2025
7 checks passed
@Jonas-Isr Jonas-Isr deleted the orch-metadata-params branch November 20, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

please-review Request to review a pull-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants