weiqingy opened a new issue, #1253:
URL: https://github.com/apache/flink-agents/issues/1253

   ### Search before asking
   
   - [x] I searched in the 
[issues](https://github.com/apache/flink-agents/issues) and found nothing 
similar.
   
   ### Description
   
   When a Java output schema has a `Map` field, the native schema sent by 
OpenAI, Azure OpenAI and Anthropic turns it into an empty object. The model can 
only return `{}`, so the map's data is lost without any error.
   
   These connections call `PojoJsonSchemaGenerator.generateAllRequired` with 
`FORBIDDEN_ADDITIONAL_PROPERTIES_BY_DEFAULT`, but without 
`MAP_VALUES_AS_ADDITIONAL_PROPERTIES`. vLLM inherits this from OpenAI. Strict 
mode requires `additionalProperties: false` on every object, so a free-form map 
has no valid strict form anyway.
   
   The other Java providers behave differently:
   - Ollama and watsonx describe the map values.
   - Gemini passes both options.
   - Bedrock sends a bare `{"type":"object"}` on purpose, because it rejects 
any `additionalProperties` other than `false`.
   
   Python OpenAI keeps `"additionalProperties": {"type": "integer"}` for a 
`dict[str, int]` field. Strict mode is expected to reject that, so the call 
would fail loudly instead. That is not tested against the live API.
   
   Proposed fix: a strict connection reports a schema that contains a free-form 
map as `INFEASIBLE`, in both languages. `AUTO` then uses the prompt path, and 
`NATIVE` fails with a clear message. The structured output guide (#1252) 
documents the limit for now.
   
   ### How to reproduce
   
   ```java
   public class Tally {
       public Map<String, Integer> counts;
   }
   ```
   
   Use it as a `ReActAgent` output schema on OpenAI, Azure OpenAI or Anthropic, 
with `AUTO` or `NATIVE`. The schema sent contains 
`"counts":{"type":"object","additionalProperties":false}`, and the parsed 
result has an empty `counts`.
   
   ### Version and environment
   
   main at dda10f62, Java connections in `integrations/chat-models`.
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!
   


-- 
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]

Reply via email to