Manuscript Offprint

arXiv:2611.06674

AgentTrustCI: Build-Time Policy, Grounding, and Trajectory Tests for Java LLM Agents

Sachin Gupta

Sachin Gupta

Independent Researcher

San Jose, California, USA

sachinkg12@gmail.com

Abstract—Infrastructure security does not establish whether an LLM agent selected an allowed tool, grounded its answer in tool output, or followed a required workflow. AgentTrustCI is a Java/JUnit 5 framework that expresses these application-layer expectations as policy, grounding, and trajectory checks over recorded traces. A deterministic replay implementation supports repeatable build-time tests; a judge interface provides an extension point for optional semantic evaluation. On 55 synthetic cases spanning seven enterprise domains, the full pipeline correctly classifies all 30 injected faults and 25 passing controls, including ten non-trivial controls, and misses none of 12 designated critical cases. Each single-layer configuration correctly classifies 35 cases because the corpus deliberately isolates ten faults per layer. A grounded answer obtained through a disallowed sequence illustrates the additional coverage of trajectory checks. Repeated measurements quantify validator execution separately from process startup and reporting. These results establish coverage of the authored regression suite, not production accuracy. We describe a production-trace validation protocol, optional LLM-judge integration, and maintenance of expectations as workflows evolve. The contribution is a practical pattern for expressing behavioral contracts within an existing Java release pipeline.

Index Terms—LLM agents, software testing, continuous integration, policy compliance, answer grounding, trajectory validation, enterprise Java.

I. INTRODUCTION

An agent can run in an attested, isolated environment and still choose the wrong tool, expose a restricted field, fabricate a result, or skip an approval step. Confidential computing protects aspects of the execution environment [1]; a release engineer also needs evidence that the application's behavior satisfies its tool and workflow expectations.

For example, an agent asked to search support tickets may call ticket.close, pass a search tool the forbidden parameter includePrivateNotes, or invent an identifier absent from every tool response. An agent may also produce a grounded answer after following a disallowed sequence. A final-answer check alone provides insufficient evidence about these execution decisions. Conventional tests can encode such expectations, but a test suite must explicitly observe calls, results, and ordering to exercise them.

AgentTrustCI expresses three expectation classes as repository-local regression tests: policy constrains tools and parameters, grounding checks selected answer claims against tool output, and trajectory constrains the sequence of calls. The implementation is a small Java/JUnit 5 prototype that

TABLE I

EXPECTATION CLASSES AND REPRESENTATIVE FAILURES

LayerExpectationFailure example
PolicyAllowed tools and parameter constraintsClose instead of search; foreign user ID; forbidden field request
GroundingSelected answer claims supported by tool resultsInvented ticket ID, quotation, or quantity; restricted-field name disclosure
TrajectoryRequired order and forbidden/repeated stepsUpdate before read; skipped lookup; grounded answer via an unapproved path

evaluates recorded traces without invoking an LLM. Its contributions are a declarative trace-and-expectation representation, a layered validator with diagnostic reason codes, and an executable evaluation that isolates the contribution of each layer.

The scope is build-time testing. The supplied replay suite tests validator behavior on fixed fixtures; detecting a regression in an evolving agent requires capturing traces from the candidate agent version and evaluating them against independently maintained expectations. Passing the supplied fixtures alone does not establish that a changed agent behaves correctly. Runtime controls and monitoring remain necessary for behavior outside the regression suite.