You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "twosom (via GitHub)" <gi...@apache.org> on 2026/04/18 01:22:21 UTC

[PR] [fix][plan] Fix parsing exception in ChatModelAction [flink-agents]

twosom opened a new pull request, #634:
URL: https://github.com/apache/flink-agents/pull/634

   <!--
   * Thank you very much for contributing to Flink Agents.
   * Please add the relevant components in the PR title. E.g., [api], [runtime], [java], [python], [hotfix], etc.
   -->
   
   <!-- Please link the PR to the relevant issue(s). Hotfix doesn't need this. -->
   Linked issue: #633 
   
   ### Purpose of change
   
   <!-- What is the purpose of this change? -->
   The ChatModelAction currently fails with a JsonParseException when an LLM returns a structured output wrapped in Markdown code blocks (e.g., ```json ... ```). This happens because Jackson's ObjectMapper expects a valid JSON start character ({ or [) but encounters a backtick (`) instead.
   so, I added a utility method to extract raw JSON string from LLM responses that include Markdown decorators.
   
   ### Tests
   
   <!-- How is this change verified? -->
   Added some unit tests for clean llm response
   
   ### API
   
   <!-- Does this change touches any public APIs? -->
   
   ### Documentation
   
   <!-- Do not remove this section. Check the proper box only. -->
   
   - [ ] `doc-needed` <!-- Your PR changes impact docs -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-included` <!-- Your PR already contains the necessary documentation updates -->
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][plan] Fix parsing exception in ChatModelAction [flink-agents]

Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 merged PR #634:
URL: https://github.com/apache/flink-agents/pull/634


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][plan] Fix parsing exception in ChatModelAction [flink-agents]

Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 commented on PR #634:
URL: https://github.com/apache/flink-agents/pull/634#issuecomment-4287646208

   Hi, @twosom, thanks for you work, LGTM.
   
   Could you also add similar logic for the Python chat model action? We should maintain consistent behavior across built-in actions to avoid unexpected outcomes.


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][plan] Fix parsing exception in ChatModelAction [flink-agents]

Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 commented on PR #634:
URL: https://github.com/apache/flink-agents/pull/634#issuecomment-4287624673

   ### Code review
   
   Found 1 issue:
   
   1. The fix is Java-only — the Python `ChatModelAction` has the same bug and was not updated. `python/flink_agents/plan/actions/chat_model_action.py` still calls `json.loads(response.content.strip())` with no fence stripping, so the same `JSONDecodeError` will occur for fenced LLM responses on the Python path. This module has historically required Java/Python parity (e.g. PR #548 was held until the Python side was updated), so reviewers will likely ask for a parallel `_clean_llm_response` helper here.
   
   https://github.com/apache/flink-agents/blob/18f2803bfc11758a925778ad686ee2e5d5d4de31/python/flink_agents/plan/actions/chat_model_action.py#L199-L203
   
   For reference, the new Java helper added in this PR:
   
   https://github.com/apache/flink-agents/blob/18f2803bfc11758a925778ad686ee2e5d5d4de31/plan/src/main/java/org/apache/flink/agents/plan/actions/ChatModelAction.java#L205-L221
   
   🤖 Generated with [Claude Code](https://claude.ai/code)
   
   <sub>- If this code review was useful, please react with 👍. Otherwise, react with 👎.</sub>
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][plan] Fix parsing exception in ChatModelAction [flink-agents]

Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 commented on PR #634:
URL: https://github.com/apache/flink-agents/pull/634#issuecomment-4293891378

   LGTM


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][plan] Fix parsing exception in ChatModelAction [flink-agents]

Posted by "twosom (via GitHub)" <gi...@apache.org>.
twosom commented on PR #634:
URL: https://github.com/apache/flink-agents/pull/634#issuecomment-4287750579

   > Could you also add similar logic for the Python chat model action? We should maintain consistent behavior across built-in actions to avoid unexpected outcomes.
   
   Thank you for your comment @wenjin272. Yes, I will add similar logic to Python and write test cases as well.


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org