Repository navigation
fix(integrations): fail closed on malformed nested decision fields - #1335
Merged
NandhaKishorM merged 1 commit intoOct 24, 2026
Merged
Conversation
NandhaKishorM#1301 refuses a top-level non-object body and NandhaKishorM#1321 refuses a non-object 'answers'. One level below both, the four consumers still trusted every nested value: they read res.get("answers", {}) -- whose {} default only fires when the key is ABSENT -- then iterated it with .items(), used each answer as a dict, called .startswith on 'choice' and compared 'noul' with '>='. A body that is a valid object but whose answers is a list, or whose answer is a string/null, or whose noul is a string/null/bool, raised AttributeError/TypeError out of the one path whose job is to fail closed. The bool case was worse than a crash: bool subclasses int, so 'noul': true read as 1.0 and raised a guardrail violation on a body nobody could read, while 'noul': null crashed; on the llamaindex multi-selector a 'probabilities' value of true ranked first as 1.0. Shared checks now live in integrations/_guard.py (answers_map, answer_number, probability_map, malformed) and are applied in crewai's and agno's route() and screen() and in all three llamaindex consumers. The policy matches the modules' existing one: a body this code cannot read raises the named RuntimeError ("Malformed decision response ..."), it is not silently treated as safe. score_violation_probability keeps its documented degrade-to-0.0 behaviour, since a score distribution is advisory there. The three registered suites now drive both surfaces of each adapter with six nested shapes plus a positive control; before the fix they reported the TypeError / bool-as-1.0 / TypeError failures above.
NandhaKishorM
added a commit
that referenced
this pull request
Oct 24, 2026
33 PRs. Server hardening (#1331, #1332, #1333), TypeScript parity (#1330, #1336, #1337, #1338, #1339, #1340, #1341, #1342, #1343), fail-closed input handling in evals and the integrations (#1317, #1318, #1319, #1320, #1321, #1322, #1326, #1335), exact and faster script detection (#1334, #1349), JVM and .NET resource handling (#1327, #1328, #1329, #1346), port goldens and clipping (#1324 excluded, #1325, #1344, #1345), CI (#1323, #1347, #1348). Verified before tagging: all 92 suites pass, 610 tests. ruff clean on both lists. laya-ts 1247 tests across 44 files, tsc --noEmit clean. Version agrees across pyproject.toml, laya.__version__ and nix/package.nix. README carries 0.4.15 only. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Shared checks in
laya/integrations/_guard.py(answers_map,answer_number,probability_map,malformed) are applied in CrewAI's and Agno'sroute()andscreen()and in all three LlamaIndex consumers, soanswers, each answer,choice,noulandprobabilitiesare validated before use.Why
#1301 refuses a top-level non-object body and #1321 refuses a non-object
answers; one level below both, the consumers still trusted every nested value. They readres.get("answers", {})(whose{}only fires when the key is ABSENT), iterated it with.items(), used each answer as a dict, called.startswithonchoiceand comparednoulwith>=, so a valid object withanswers: [],{"q": null},{"noul": "high"}or{"noul": true}raisedAttributeError/TypeErrorout of the one path whose job is to fail closed. The bool case was worse than a crash:boolsubclassesint, sonoul: trueread as 1.0 and raised a guardrail violation on a body nobody could read; in the LlamaIndex multi-selector aprobabilitiesvalue oftrueranked first as 1.0.How it was verified
Checklist
main(branch cut fromupstream/mainat 0.4.14)