davsclaus opened a new pull request, #26567:
URL: https://github.com/apache/camel/pull/26567
What the model writes goes through the validator before `camel_write_file`
writes it; what it says in the answer did not, and the answer is what the user
copies. With a local Ollama model the recurring slip is the operator inside the
placeholder, `${header.user ?: 'Guest'}` instead of `${header.user} ?:
'Guest'`, even after the model has seen the correct example.
### What changes
- **`AnswerChecks`** (camel-jbang-core, `commands.ai`): extracts the simple
expressions of an answer and validates them with the catalog, the way
`camel_validate_source` checks a route. The `${...}` placeholders of the text
and of the non-YAML code blocks are checked one by one, but only those that
start with a simple function or value from the catalog (`body`, `header`,
`random`, `date`, ...), so a Maven `${camel-version}` or a shell variable in
the same answer is left alone. YAML blocks go through the existing
`SimpleChecks` (their `simple:` values and log messages). What the catalog
cannot judge is skipped as in the file validator: a function of a language that
is not on the classpath, a property placeholder used as a logical operand.
- **The AI panel** (camel-jbang-plugin-tui): when the model's answer has an
invalid expression, the panel sends it back once, within the tool-call budget,
with the expression, the catalog's error and the rule (functions inside
`${...}`, operators between placeholders). The corrected answer is shown with
`1 correction` in the byline, so it is measurable how often a model needs it.
An answer the model does not fix is shown as it is, with a *Simple check* line
under it naming the expression and the error. A wrap-up answer after the
tool-call limit gets the note but no correction turn. The exchange is in the AI
log.
- The `ConversationEntry` record carries `corrections` and `note`; the
shorter constructors are unchanged.
- The TUI page describes the check under the byline paragraph.
Out of scope, as on the JIRA: the external MCP server, where the client
renders the answer and the tools already validate what is written.
### Testing
- `AnswerChecksTest` (5): the operator inside the placeholder found in prose
and inline code, correct and foreign placeholders passing, YAML blocks checked
as routes and Java blocks as text, balanced placeholders, the default catalog.
- `AiPanelTest` (+3, 78 in all) with a scripted client that answers wrong
and fixes on request, never fixes, or is right the first time: one correction
turn at most, the byline, the note, no error entry.
- `AiPanelPromptBudgetTest` unchanged: no tool schema or system prompt text
changed.
_Claude Code on behalf of davsclaus_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]