Skip to content

Update fdm-agents dependencies, agent class, and constraints#592

Merged
SvenVw merged 9 commits into
developmentfrom
chore/update-adk
Apr 30, 2026
Merged

Update fdm-agents dependencies, agent class, and constraints#592
SvenVw merged 9 commits into
developmentfrom
chore/update-adk

Conversation

@SvenVw
Copy link
Copy Markdown
Collaborator

@SvenVw SvenVw commented Apr 29, 2026

Summary by CodeRabbit

  • Dependencies

    • Updated core agent framework, monitoring, and validation packages.
  • New Features

    • Added crop-specific fertilizer guide + lookup used early in planning.
    • Plans now include a per-field explanation ("field summary") visible in the UI.
  • Improvements

    • Planner prioritizes meeting N/P/K advice (especially N) under constraints; tightened rotation and simulation requirements; stronger tool sequencing.
    • Robust JSON-repair fallback for truncated planner responses.
  • Documentation

    • Extensive crop-specific fertilizer reference sheets and release notes added.

@SvenVw SvenVw self-assigned this Apr 29, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

Warning

Rate limit exceeded

@SvenVw has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 35 minutes and 27 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c55ecea4-1ba9-4571-9411-a8cf7dc79be1

📥 Commits

Reviewing files that changed from the base of the PR and between dae7e0d and af09c2f.

📒 Files selected for processing (3)
  • .changeset/violet-ravens-wonder.md
  • fdm-agents/src/tools/fertilizer-planner/index.ts
  • fdm-app/app/routes/farm.$b_id_farm.$calendar.gerrit.tsx
📝 Walkthrough

Walkthrough

Adds a crop-specific fertilizer guidance skill and assets, registers a new getCropFertilizerGuide tool, requires early use of that guide in the Gerrit planner, updates tool/simulation logic and UI to include per-field summaries, bumps runtime deps, updates build copying of skills, and improves JSON-repair and telemetry truncation.

Changes

Cohort / File(s) Summary
Release metadata
/.changeset/eleven-moments-relate.md, /.changeset/funky-papers-allow.md, /.changeset/violet-ravens-wonder.md
New changeset files documenting patch/minor releases and notes about NPK prioritization, crop-specific guidance, and per-field explanations.
Dependencies & build
fdm-agents/package.json, fdm-agents/tsdown.config.ts
Bumped dependencies (@google/adk → ^1.1.0, posthog-node → ^5.30.8, zod → ^4.3.6) and added a tsdown build plugin to copy src/skillsdist/skills.
Agent behavior & contract
fdm-agents/src/agents/gerrit/agent.ts
Swapped ADK class usage to Agent, tightened planner instructions to require early getCropFertilizerGuide, prioritize satisfying crop NPK (N first) over OM under constrained norms, require per-field plan entries and simulation across all fields, and changed server response to include fieldSummary (removed fieldMetrics).
Fertilizer planner tools & tests
fdm-agents/src/tools/fertilizer-planner/index.ts, fdm-agents/src/tools/fertilizer-planner/index.test.ts
Removed as any casts on Zod parameter schemas, added getCropFertilizerGuide tool (loads assets/crop-index.json and referenced markdowns, dedupes/concats guides), adjusted farm-level norms computation to use all eligible fields; test updated to expect 6 tools and presence of getCropFertilizerGuide.
Crop-specific skill assets
fdm-agents/src/skills/crop-specific-fertilizer-preferences/*
New skill directory with SKILL.md, assets/crop-index.json, .gitkeep placeholders, scripts, and many per-crop references/*.md files encoding prefer/avoid/attention rules used by the new tool.
App UI & types
fdm-app/app/components/blocks/gerrit/plan-table.tsx, fdm-app/app/components/blocks/gerrit/types.ts
Expandable plan rows extended to show expansion when fieldSummary exists; ParsedPlan/PlanRow types updated to include optional fieldSummary.
Server route & telemetry
fdm-app/app/routes/farm.$b_id_farm.$calendar.gerrit.tsx
Added JSON-repair fallback for truncated plan JSON, filters b_bufferstrip fields and sets b_bufferstrip=false for remaining fields, exposes per-field fieldSummary to client, and increases PostHog truncation limits (2000→100000 chars).

Sequence Diagram(s)

sequenceDiagram
  participant Client as User
  participant Agent as FertilizerPlannerAgent
  participant Tools as PlannerTools
  participant FS as SkillAssets

  Client->>Agent: Request fertilizer plan
  Agent->>Tools: getFarmFields()
  Tools-->>Agent: fields (with b_lu_catalogues)
  Agent->>Tools: getCropFertilizerGuide(b_lu_catalogues)
  Tools->>FS: read assets/crop-index.json & references/*.md
  FS-->>Tools: matched guides (concatenated)
  Tools-->>Agent: crop guides + matchedFiles
  Agent->>Tools: getFarmNutrientAdvice(), getFarmLegalNorms(), searchFertilizers(), simulateFarmPlan(all fields)
  Tools-->>Agent: advice, norms, fertilizers, simulationResults
  Agent-->>Client: plan (per-field plan + fieldSummary)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

Suggested labels

enhancement, fdm-app, branch:development

Suggested reviewers

  • BoraIneviNMI
  • gerardhros

Poem

🐰
I nibble indexes and hop through guides,
A crop-by-crop whisper before the planner decides.
N leads, OM waits, each field gets a line,
New tools, neat notes — the harvest will shine! 🌱

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title Check ✅ Passed Title check skipped as CodeRabbit has written the PR title.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/update-adk

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 35 minutes and 27 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot changed the title @coderabbitai Update fdm-agents dependencies, agent class, and constraints Apr 29, 2026
@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 35.13514% with 24 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
fdm-agents/src/tools/fertilizer-planner/index.ts 33.33% 24 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
fdm-agents/src/agents/gerrit/agent.ts (1)

38-47: Consolidate duplicated prioritization guidance in the prompt.

Line 38 and Line 47 both restate the same NPK-over-OM constraint. Keeping one canonical instruction would reduce prompt bloat and avoid interpretation drift.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@fdm-agents/src/agents/gerrit/agent.ts` around lines 38 - 47, The prompt
guidance block contains a duplicated prioritization rule that NPK advice
(especially N) takes priority over improving organic matter (OM) — remove the
redundant sentence and keep a single canonical statement that NPK-over-OM
applies; locate the guidance block that mentions p_type, b_bufferstrip and
p_app_method_options (the rules list including application amounts and realistic
dates) and delete the repeated NPK-over-OM line, retaining the clearest
phrasing, then renumber/adjust surrounding items and any references to that rule
so only one authoritative prioritization sentence remains.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@fdm-agents/src/agents/gerrit/agent.ts`:
- Around line 38-47: The prompt guidance block contains a duplicated
prioritization rule that NPK advice (especially N) takes priority over improving
organic matter (OM) — remove the redundant sentence and keep a single canonical
statement that NPK-over-OM applies; locate the guidance block that mentions
p_type, b_bufferstrip and p_app_method_options (the rules list including
application amounts and realistic dates) and delete the repeated NPK-over-OM
line, retaining the clearest phrasing, then renumber/adjust surrounding items
and any references to that rule so only one authoritative prioritization
sentence remains.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: be842186-81e5-4077-84a3-7e96aec25c2a

📥 Commits

Reviewing files that changed from the base of the PR and between c7da915 and 90b14e9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • .changeset/eleven-moments-relate.md
  • fdm-agents/package.json
  • fdm-agents/src/agents/gerrit/agent.ts
  • fdm-agents/src/tools/fertilizer-planner/index.ts

@SvenVw SvenVw requested a review from BoraIneviNMI April 29, 2026 14:27
@SvenVw SvenVw marked this pull request as draft April 29, 2026 14:44
@SvenVw SvenVw removed the request for review from BoraIneviNMI April 29, 2026 14:44
@SvenVw SvenVw marked this pull request as ready for review April 29, 2026 15:40
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/boomkwekerij.md (1)

56-56: Polish phrasing for clearer English readability.

At Line 56, consider changing “yellow old needles” to “yellowing of older needles” (or “yellow older needles”) to avoid awkward adjective order in an otherwise polished reference doc.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/boomkwekerij.md`
at line 56, Update the phrasing in the reference sentence "K, Mg and S per
advice — Mg deficiency causes the typical yellow old needles." by replacing
"yellow old needles" with a clearer wording such as "yellowing of older needles"
(or "yellow older needles") so the sentence reads e.g. "K, Mg and S per advice —
Mg deficiency causes the typical yellowing of older needles."; locate and edit
the exact sentence text in the document (the string "K, Mg and S per advice — Mg
deficiency causes the typical yellow old needles.").
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/funky-papers-allow.md:
- Line 5: Update the release note sentence "Add skill for crop specific
fertilizer preferences" to use a hyphenated compound adjective by changing it to
"Add skill for crop-specific fertilizer preferences" so the phrase is
grammatically correct; locate the sentence in the .changeset release note (the
line containing "crop specific") and replace it with the hyphenated form.

In `@fdm-agents/src/skills/crop-specific-fertilizer-preferences/SKILL.md`:
- Around line 83-84: The phrase "soil-type dependent" in SKILL.md should be
hyphenated consistently as "soil-type-dependent"; locate the exact text
"soil-type dependent" in the sentence starting "When soil-type dependent
recommendations apply..." and replace it with "soil-type-dependent" to match the
document's compound adjective style.
- Around line 42-44: The doc's rule that agents "pick the subsection whose
catalogue codes match the field" is unsafe for shared codes (e.g.,
aardappelen.md's "consumptie"); update SKILL.md to add an explicit
disambiguation rule: when catalogue codes are shared across subsections, the
agent must also match a secondary context field (e.g., "destination" or "use"
such as frites vs tafel) before selecting a subsection, and if that secondary
context is missing it must either request the field from the user or fall back
to not selecting that ambiguous subsection; mention "consumptie" as an example
and apply the same clarification to the similar sentence at lines 46–48.

In `@fdm-agents/tsdown.config.ts`:
- Line 1: The skills-copy step uses CWD-relative paths causing failures when
builds run outside fdm-agents; update the path construction used with cpSync and
mkdirSync to derive absolute paths from the config file location (use
import.meta.url -> fileURLToPath -> path.dirname or __dirname equivalent) and
then path.join/path.resolve to build both source and destination for the skills
copy, and adjust the cpSync/mkdirSync calls to use those resolved paths (add
required imports from "node:path" and "node:url" if needed).

---

Nitpick comments:
In
`@fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/boomkwekerij.md`:
- Line 56: Update the phrasing in the reference sentence "K, Mg and S per advice
— Mg deficiency causes the typical yellow old needles." by replacing "yellow old
needles" with a clearer wording such as "yellowing of older needles" (or "yellow
older needles") so the sentence reads e.g. "K, Mg and S per advice — Mg
deficiency causes the typical yellowing of older needles."; locate and edit the
exact sentence text in the document (the string "K, Mg and S per advice — Mg
deficiency causes the typical yellow old needles.").
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a2ebc2be-e3a7-4ac8-a038-4b52ead334e2

📥 Commits

Reviewing files that changed from the base of the PR and between 90b14e9 and 9b8c9b1.

📒 Files selected for processing (41)
  • .changeset/funky-papers-allow.md
  • fdm-agents/src/agents/gerrit/agent.ts
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/SKILL.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/assets/.gitkeep
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/assets/crop-index.json
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/aardappelen.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/aardperen.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/asperges.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/bloembollen.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/boomkwekerij.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/consumptieaardappelen.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/extensiefgrasland.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/fruitteelt.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/grasland.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/graszaad.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/haver.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/klaver.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/knolselderij.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/koolgewassen.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/koolzaad.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/luzerne.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/mais.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/natuurgrasland.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/peen.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/peulvruchten.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/prei.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/rogge.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/sla-andijvie.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/spinazie.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/suikerbieten.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/uien.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/vlas.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/voederbieten.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/vroegeaardappelen.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/wintergerst-zomergerst.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/wintertarwe-zomertarwe.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/witlofwortel.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/scripts/.gitkeep
  • fdm-agents/src/tools/fertilizer-planner/index.test.ts
  • fdm-agents/src/tools/fertilizer-planner/index.ts
  • fdm-agents/tsdown.config.ts
✅ Files skipped from review due to trivial changes (26)
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/assets/.gitkeep
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/scripts/.gitkeep
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/haver.md
  • fdm-agents/src/tools/fertilizer-planner/index.test.ts
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/natuurgrasland.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/witlofwortel.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/rogge.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/koolzaad.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/koolgewassen.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/suikerbieten.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/luzerne.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/prei.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/extensiefgrasland.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/aardperen.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/knolselderij.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/vroegeaardappelen.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/peen.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/voederbieten.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/fruitteelt.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/wintergerst-zomergerst.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/bloembollen.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/vlas.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/spinazie.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/mais.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/uien.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/klaver.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • fdm-agents/src/tools/fertilizer-planner/index.ts

Comment thread .changeset/funky-papers-allow.md Outdated
Comment thread fdm-agents/src/skills/crop-specific-fertilizer-preferences/SKILL.md
Comment thread fdm-agents/src/skills/crop-specific-fertilizer-preferences/SKILL.md Outdated
Comment thread fdm-agents/tsdown.config.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
fdm-app/app/routes/farm.$b_id_farm.$calendar.gerrit.tsx (1)

822-829: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Server-side farmTotals can now disagree with Gerrit’s simulation.

This PR updated simulateFarmPlan to compute legal norms from all eligible farm fields, but computePlanMetrics() still recomputes totals from the enriched plan fields only. Returning serverMetrics here means the UI can show different farm limits than the numbers Gerrit optimized against. Please align the recomputation logic with fdm-agents/src/tools/fertilizer-planner/index.ts before overwriting the tool output.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@fdm-app/app/routes/farm`.$b_id_farm.$calendar.gerrit.tsx around lines 822 -
829, Server-side farmTotals are being recomputed from enrichedPlan via
computePlanMetrics and can diverge from Gerrit’s simulation which now computes
legal norms from all eligible farm fields in simulateFarmPlan; update the code
so serverMetrics uses the same recomputation logic as
fdm-agents/src/tools/fertilizer-planner/index.ts (i.e., compute totals from all
eligible farm fields, not only enrichedPlan fields) by either (A) changing the
call to computePlanMetrics to pass the full eligible-fields list used by
simulateFarmPlan or (B) updating computePlanMetrics implementation to mirror the
fertilizer-planner logic; ensure you reference computePlanMetrics,
simulateFarmPlan, enrichedPlan and serverMetrics and preserve the original tool
output’s farmTotals rather than overwriting them with inconsistent recomputed
values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/violet-ravens-wonder.md:
- Line 6: Replace the misspelled word "explaination" with the correct spelling
"explanation" in the release note text (the sentence "Add a short field-level
explaination for the fertilizer plan generated by Gerrit to gain more insights
in the provided plan" in .changeset/violet-ravens-wonder.md) so the user-facing
changelog uses the correct term.

In `@fdm-agents/src/tools/fertilizer-planner/index.ts`:
- Around line 1000-1007: The tool currently requires b_lu_catalogues to be
string[] but getFarmFields can return nulls; update the parameters schema for
b_lu_catalogues to accept nullable entries (e.g., array of string | null) and
inside execute (the execute: async (input: { b_lu_catalogues: string[] }) => {
... }) filter out falsy/null values before use (e.g., const cleaned =
input.b_lu_catalogues.filter(Boolean)) so downstream code only receives real
strings; reference the parameters object and the execute handler when making
these changes.
- Around line 692-725: The current mapping over allFarmFields swallows errors in
the try/catch (collectInputForNorms / calculateNormForManure /
calculateNormForPhosphate / calculateNormForNitrogen) by returning null, which
silently removes fields from allFarmFieldNorms and causes incorrect farm-level
totals; instead either let the Promise fail (remove the catch so Promise.all
rejects) or capture and propagate failing field IDs: replace the empty catch
with logic that records f.b_id into a shared failedFields array (or throw a new
Error listing the failed IDs) and ensure the downstream consumer that builds
farmNormsKg checks for failedFields and aborts the simulation or surfaces those
IDs rather than omitting them. Ensure references to allFarmFieldNorms and
farmNormsKg handle the propagated error/failed list accordingly.

In `@fdm-app/app/routes/farm`.$b_id_farm.$calendar.gerrit.tsx:
- Around line 177-185: The local variable named escape is shadowing the global
escape and fails lint; rename it (e.g., to isEscaped or escaping) throughout the
helper (the variable declared on Line 178 and all uses in the loop: the if
(escape) check, escape = false assignment, and escape = true assignment) so the
loop that iterates over trimmed with for (const ch of trimmed) no longer uses
the global name and passes lint.
- Around line 736-753: After calling repairTruncatedJson(truncated) and parsing
into parsedPlan, validate that the repaired parsedPlan contains all required
non-buffer fields (the core plan entries you later expand into enrichedPlan)
before proceeding; if any required fields are missing or shortened compared to
expected schema, return dataWithError(null, "Gerrit gaf een ongeldig plan terug.
Probeer het opnieuw.") instead of accepting the partial plan. Locate the block
that slices rawResult (using firstBrace/lastBrace), the repairTruncatedJson
call, and the parsedPlan variable, then add a lightweight schema/field presence
check (e.g., required top-level keys and non-buffer arrays/objects) and fail
closed when validation fails so enrichedPlan and subsequent fertilizer
application logic never operate on a truncated plan.

---

Outside diff comments:
In `@fdm-app/app/routes/farm`.$b_id_farm.$calendar.gerrit.tsx:
- Around line 822-829: Server-side farmTotals are being recomputed from
enrichedPlan via computePlanMetrics and can diverge from Gerrit’s simulation
which now computes legal norms from all eligible farm fields in
simulateFarmPlan; update the code so serverMetrics uses the same recomputation
logic as fdm-agents/src/tools/fertilizer-planner/index.ts (i.e., compute totals
from all eligible farm fields, not only enrichedPlan fields) by either (A)
changing the call to computePlanMetrics to pass the full eligible-fields list
used by simulateFarmPlan or (B) updating computePlanMetrics implementation to
mirror the fertilizer-planner logic; ensure you reference computePlanMetrics,
simulateFarmPlan, enrichedPlan and serverMetrics and preserve the original tool
output’s farmTotals rather than overwriting them with inconsistent recomputed
values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: dd3ecaa5-aa8a-4731-9715-77cccaca0798

📥 Commits

Reviewing files that changed from the base of the PR and between 9b8c9b1 and dae7e0d.

📒 Files selected for processing (10)
  • .changeset/funky-papers-allow.md
  • .changeset/violet-ravens-wonder.md
  • fdm-agents/src/agents/gerrit/agent.ts
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/SKILL.md
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/boomkwekerij.md
  • fdm-agents/src/tools/fertilizer-planner/index.ts
  • fdm-agents/tsdown.config.ts
  • fdm-app/app/components/blocks/gerrit/plan-table.tsx
  • fdm-app/app/components/blocks/gerrit/types.ts
  • fdm-app/app/routes/farm.$b_id_farm.$calendar.gerrit.tsx
✅ Files skipped from review due to trivial changes (3)
  • .changeset/funky-papers-allow.md
  • fdm-app/app/components/blocks/gerrit/types.ts
  • fdm-agents/src/skills/crop-specific-fertilizer-preferences/references/boomkwekerij.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • fdm-agents/tsdown.config.ts

Comment thread .changeset/violet-ravens-wonder.md Outdated
Comment thread fdm-agents/src/tools/fertilizer-planner/index.ts
Comment thread fdm-agents/src/tools/fertilizer-planner/index.ts Outdated
Comment thread fdm-app/app/routes/farm.$b_id_farm.$calendar.gerrit.tsx Outdated
Comment thread fdm-app/app/routes/farm.$b_id_farm.$calendar.gerrit.tsx
@SvenVw SvenVw requested a review from BoraIneviNMI April 30, 2026 09:32
@SvenVw SvenVw merged commit b3ffb64 into development Apr 30, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant