Urgent.News

What's breaking now, across thousands of outlets.

Tech

Your Agent Saved the File. Who Checked the Result?

The tool call succeeds. The file exists. The agent says, “Done.” Then someone opens it and finds the wrong total. Nothing crashed. The system answered a smaller question than the customer asked. “Did the file write finish?” and “Does the delivered report meet the request?” are different checks. This tutorial builds a small example you can run without a model, then shows how the same distinction…

The tutorial demonstrates creating a small report verification tool to check the accuracy of generated files. The core idea is to define the completion criteria before relying on the agent to declare success. In this case, the verification must confirm the exact report ID, revision number, item quantities, and total units match the trusted input provided at the start of the task.

The verification code is written in JavaScript and uses the crypto library to compute a SHA256 hash of the delivered file bytes. It then attempts to parse the bytes as JSON. If the parsing fails or the parsed object is invalid, the verification returns false along with an error message.

The verification proceeds by checking if the report ID and revision number match the expected values. It also validates that the rows array contains only valid row objects with string item names and safe integer unit quantities. Additionally, it checks for duplicate item names and compares the actual number of rows with the expected number, as well as verifying each row's item and units match the expected values.

Finally, the verification calculates the sum of all units in the rows and compares it to the total_units field in the delivered report. If any of these checks fail, the verification returns false with appropriate error messages. Otherwise, it returns true, indicating the verification was successful.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Sunday 27 September →