← Back to AI Insights
Gemini Executive Synthesis

LLM response parsing failure (JSON wrapped in markdown code blocks)

Technical Positioning
Robust LLM integration and reliable content parsing for novel generation
SaaS Insight & Market Implications
This issue highlights a critical integration fragility: LLM output format inconsistencies. Vertex AI's Gemini models wrapping JSON in markdown code blocks breaks `inkos`'s `state-validator.js` parser. This directly impedes core autonomous novel writing functionality, preventing chapter audits and saves. The pain point is unexpected variability in LLM API responses, forcing developers to implement highly specific parsing logic for each provider/model. Market implication: SaaS platforms relying on diverse LLM backends must anticipate and robustly handle non-standard outputs, or risk significant operational friction and user dissatisfaction. This parsing failure directly impacts content generation workflow, leading to stalled progress and wasted compute.
Proprietary Technical Taxonomy
Vertex AI Gemini3.1 pro Gemini2.5 pro md代码块 state-validator.js parseResult JSON.parse inkos write next

Raw Developer Origin & Technical Request

Source Icon GitHub Issue Mar 29, 2026
Repo: Narcooo/inkos
inkos write next 每次都不成功,openclaw告诉我是state-validator.js的锅,请求修复指导🙏

### What happened?

作者大大辛苦啦,想请教:

我拿了Vertex AI 做了一层API KEY的代理,然后因为用的是Gemini3.1 pro的接口,很神奇地发现inkos write next 每次都不成功,然后查原因,Openclaw告诉我,每次写完之后,内容被包裹在md的代码块里。

openclaw多次提醒我:

“该端点的 Gemini 模型返回 JSON 时总是包裹在 markdown 代码块里,而 inkos 的解析器不处理这种格式”、“问题来源是state-validator.js的parseResult“、“这个 API 端点返回的 JSON 被包在 markdown 代码块里(```json ... ```),inkos 的 state-validator 解析时没处理这种格式,导致 JSON.parse 失败”

想问一下,这种从vertex AI 调用 gemini2.5 pro 或者gemini3.1 pro,回出现这种JSON被包在markdown 代码块里,导致小说write后无法过审和保存的问题,有什么办法解决么?

### Steps to reproduce

1.搭建Vertex AI的代理
2.将自己搭的代理API key 应用于inkos
3.inkos doctor 测试调通
4.开始inkos write next
5.多次始终无法通过(写完无法通过审核,无法保存)
6.查找问题,发现是上述提到的原因

### Expected behavior

原本应该可以跑完模型就存下新的一个章节

### InkOS version

0.63

### Operating system

Linux

### LLM provider / model

vertex AI(Gemini3.1 pro)

### Relevant logs

```shell

```

Developer Debate & Comments

Narcooo • Mar 30, 2026
Checked `master@ca154b5` on 2026-03-30. Current `StateValidatorAgent.parseResult()` on mainline no longer requires raw plain JSON; it scans the response and extracts the first valid JSON object, so fenced ```json blocks are accepted now. I reran `packages/core/src/__tests__/state-validator-agent.test.ts` locally today and it passes. If this still reproduces on `0.6.3` behind a Vertex proxy, please paste the exact raw validator response: the remaining failure may be elsewhere in the provider / proxy chain, not in the current mainline parser.
znhacker • Mar 30, 2026
> `master@ca154b5`已于 2026-03-30检查。`StateValidatorAgent.parseResult()`主线版本不再需要原始纯 JSON;它会扫描响应并提取第一个有效的 JSON 对象,因此现在可以接受用 ```json 块分隔的 JSON 对象。 > > 我`packages/core/src/__tests__/state-validator-agent.test.ts`今天在本地重新运行了一遍,测试通过了。如果这个问题在 Vertex 代理后仍然存在`0.6.3`,请粘贴完整的原始验证器响应:剩余的错误可能出在提供程序/代理链的其他环节,而不是当前主线解析器本身。 @Narcooo 感谢,已经通过了,我的一直不通过的问题是两个原因导致的: 1、0.63版中,write仍然出现了——“State validator returned invalid response: Error: missing boolean 'passed' field”,核心原因是:Gemini 返回的 JSON 里没有 passed 字段(或者整个 JSON 格式不对),导致 schema 校验失败然后抛错。这不是 code fence 的问题——是 LLM 返回的 JSON 结构不符合预期(缺少 passed: boolean)。0.6.3 的 extractBalancedJsonObject 能正确提取 JSON,但提取出来的内容本身不含 passed 字段。 实际问题定位,0.6.3 的 parseResult 里这行: if (typeof parsed.passed !== "boolean") { throw new Error("missing boolean 'passed' field"); } 所以,extractFirstValidJsonObject 能正确提取到 JSON 对象,但 Gemini 返回的 JSON 里 passed 字段不是 boolean(可能是字符串 "true" 或完全缺失),然后直接 throw 而不是 fail-open。没有容错——Gemini 返回的 JSON 结构不完整时直接抛错,而不是降级处理 解决方案:最小化 patch——只改 pars...
znhacker • Mar 30, 2026
@Narcooo 刚升级了1.0.0,但在不自己打patch的情况下,1.0.0 原版的 StateValidator 还是会崩,报错和之前完全一样:“State validator returned invalid JSON”

Adjacent Repository Pain Points

Other highly discussed features and pain points extracted from Narcooo/inkos.

Extracted Positioning
Performance degradation and excessive token usage in long-form content generation due to 'full context injection'
Optimizing LLM context management for scalability and efficiency in long-form content generation
Top Replies
Evan-Pycraft • Mar 23, 2026
不过话又说回来很多很多时候优化过度了会导致小说情节出现问题 不知道大佬设计思路是怎么样的 有时候有些事情鱼和熊掌不可兼得除非大模型上下文又大速度又快 😄
Narcooo • Mar 23, 2026
全量注入在早期是很有用的,不过写到长篇导致上下文,记忆和质量的系统性原因,大更新正在加紧测试中!!
Evan-Pycraft • Mar 23, 2026
原来如此 期待你的大更新 我这边持续测试!
Extracted Positioning
Architectural design ideas and questions for an AI novel generation system, focusing on RAG, state management, character intelligence, narrative consistency, and feedback loops
Advanced architectural design for scalable, consistent, and intelligent AI novel generation, addressing complex narrative challenges
Top Replies
a1640727878 • Mar 20, 2026
有一说一,都在做这个啊_(:з」∠)_我也在折腾,不过是基于AI小镇那套思维,给主角和NPC一些自主能动性,自主动的按照自己人设运行,但是运行过程又全程基于游戏,回头再看游戏日志就好,不过现在游戏层卡着我有点...
xingzihai • Mar 20, 2026
> 有一说一,都在做这个啊_(:з」∠)_我也在折腾,不过是基于AI小镇那套思维,给主角和NPC一些自主能动性,自主动的按照自己人设运行,但是运行过程又全程基于游戏,回头再看游戏日志就好,不过现在游戏层卡着我有...
Narcooo • Mar 20, 2026
我觉得你设计的挺好的,也欢迎pr,有一点就是我个人不太推荐RAG。
Extracted Positioning
Inconsistent API key validation between `inkos doctor` and `inkos write next`, leading to 401 errors during chapter generation
Consistent and reliable API key validation across all operational modes
Top Replies
JayRong • Mar 20, 2026
nkos config show-global 能看到配置如下: ``` (base) jayrome@MacBookPro my-xhnovel % inkos config show-global # InkOS Global LLM Configuration INKOS_LLM_PROVIDER=openai INKOS_LLM_BASE_URL=https://da...
JayRong • Mar 20, 2026
nkos config show-global 能看到配置如下: ``` (base) jayrome@MacBookPro my-xhnovel % inkos config show-global # InkOS Global LLM Configuration INKOS_LLM_PROVIDER=openai INKOS_LLM_BASE_URL=https://da...
YouJin-Li • Mar 20, 2026
检查一下API_KEY是否正确,一般就是key有问题,你可以让豆包或者deepseek帮你写个测试脚本,测试一下
Extracted Positioning
Chapter generation stalling or 'breaking' mid-process, particularly for new books and the first chapter
Reliable and complete chapter generation for new projects
Top Replies
vccyb • Mar 15, 2026
hello,你好,请问哪里获取对呀claude 的 api key呢,有什么渠道购买嘛
HeavenZhi • Mar 15, 2026
> hello,你好,请问哪里获取对呀claude 的 api key呢,有什么渠道购买嘛 这里可以买,还便宜:https://ai-api.db-kj.com/register?aff=uGqz
Chang-Tao • Mar 15, 2026
> hello,你好,请问哪里获取对呀claude 的 api key呢,有什么渠道购买嘛 实测发现 GPT-5.4比较好用, 还有项目的超时方面似乎不太完善, 会断流. 我自己改了,目前生成到20章了. 不过长度目前不受控制, 限制的4000...
Extracted Positioning
API key authentication failure when using custom providers and multiple agents/routes
Reliable API key management and authentication for custom LLM providers and multi-agent configurations
Top Replies
luopan88 • Mar 22, 2026
我使用inkos doctor,同样的配置是能够通的,两个网址上稍有差别,但是诊断都能通 恢复为全局默认的就正常了
celagoor • Mar 23, 2026
模型缓存 Key 未包含认证信息,共享同一个缓存 key,等作者更新
Narcooo • Mar 23, 2026
感谢报告,问题确认,预计将在下一次大规模更新中修复

Frequently Asked Questions

Market intelligence mapped to LLM response parsing failure (JSON wrapped in markdown code blocks).

How is LLM response parsing failure (JSON wrapped in markdown code blocks) positioned in the market?
Based on our AI analysis of the original developer request, its primary technical positioning is: Robust LLM integration and reliable content parsing for novel generation
Are engineers actively discussing LLM response parsing failure (JSON wrapped in markdown code blocks)?
Yes, we have tracked 3 direct responses and active debates regarding this specific topic originating from GitHub Issue.
What architecture is tied to LLM response parsing failure (JSON wrapped in markdown code blocks)?
Our proprietary extraction maps LLM response parsing failure (JSON wrapped in markdown code blocks) to adjacent architectural concepts including Vertex AI, Gemini3.1 pro, Gemini2.5 pro, md代码块.

Engagement Signals

3
Replies
open
Issue Status

Cross-Market Term Frequency

Quantifies the cross-market adoption of foundational terms like audit-failed and Vertex AI by tracking occurrence frequency across active SaaS architectures and enterprise developer debates.