wenjin272 commented on code in PR #1206:
URL: https://github.com/apache/flink-agents/pull/1206#discussion_r4245153582
##########
api/src/main/java/org/apache/flink/agents/api/agents/ReActAgent.java:
##########
@@ -152,32 +205,60 @@ public static void startAction(Event event, RunnerContext
ctx) {
}
} else {
if (userPrompt == null) {
- throw new RuntimeException(
- String.format(
- "The input type is %s, which is not primitive
types,"
- + " user should provide prompt to help
convert it to ChatMessage",
- input.getClass()));
- }
-
- Map<String, String> fields = new HashMap<>();
- if (input instanceof Row) {
- Row userInput = (Row) input;
- for (String name :
Objects.requireNonNull(userInput.getFieldNames(true))) {
- fields.put(name, String.valueOf(userInput.getField(name)));
- }
- } else { // regard as pojo
- ObjectMapper objectMapper = new ObjectMapper();
- try {
- fields =
mapper.readValue(objectMapper.writeValueAsString(input), Map.class);
- } catch (JsonProcessingException e) {
+ if (isDefaultSubagentInputMap(input)) {
Review Comment:
Could we keep ReAct's private prompt resources local to the child agent? A
child constructed with `prompt=null` and `outputSchema=null` can still pick up
the parent's `_default_user_prompt` and `_default_schema_prompt`:
`startAction()` resolves these through `ctx.getResource()`, and the child
`ResourceCache` falls back to the root cache when the name is absent locally.
Consequently, the prompt-free path here is bypassed whenever the parent has a
prompt.
I reproduced both cases through the operator harness on this head:
- Parent prompt `PARENT ONLY: {input}`, bare child, delegation arguments
`{"input":"review the diff"}`: the child model receives `PARENT ONLY: review
the diff` instead of `review the diff`.
- Parent configured with a POJO output schema, bare child: the child model
also receives the parent's JSON-schema instruction despite having no output
schema of its own.
The cache fallback predates this PR, but the newly supported ReAct
parent/child composition still needs to account for it. Could we make these
internal prompt lookups scope-local while preserving ordinary shared-resource
lookup, and add regression tests with a configured parent and an unconfigured
child?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]