Add AGENTS.md agent instructions - #64
roninsightrx wants to merge 4 commits into
Conversation
Use AGENTS.md instead of CLAUDE.md so the instructions are picked up by
any agent harness that reads the AGENTS.md convention, and make the
content harness-agnostic.
Also corrects and extends the existing guidance:
- The estimation approach is selected by `type` ("map"/"pls"/"ls"), not
by `method`, which is the `optim()` method (default "BFGS"). The old
text conflated the two.
- Documents `weight_prior` (SD scale, squared into `weight_prior_var`)
as the separate control over prior strength.
- Notes that README.md's `map_flat_prior` does not match the `pls` value
the code actually accepts.
- Adds the non-obvious `ll_func_generic` fallback for non-cpp models and
the FOCE-Jacobian-vs-numDeriv-Hessian vcov interaction.
- Adds mixture model handling, the return object shape (including that
optimizer failures return the error object rather than throwing), and
more detail on test layout, the NONMEM fixtures with hard-coded
reference values, and the CI workflow.
Commands, architecture, and test layout verified against the repo:
devtools::load_all(), devtools::test() and the filter form all run
clean.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
roninsightrx
left a comment
There was a problem hiding this comment.
Changes requested: AGENTS.md contains factual instructions that would mislead coding agents.
-
AGENTS.md:32-33—devtools::check("--no-manual --as-cran")passes that string as the positionalpkgargument rather than as check flags, so it attempts to check a package path with that name. Replace it withdevtools::check(args = c("--no-manual", "--as-cran")), matching.github/workflows/R-CMD-check.yaml:51-55. -
AGENTS.md:35-36— PKPDsim is a public repository, soremotes::install_github("InsightRX/PKPDsim")does not requirePAT_TOKEN; moreover, remotes recognizesGITHUB_PAT, not a variable namedPAT_TOKEN. Say that a token is optional for rate limits, or explain separately that CI mapssecrets.PAT_TOKENtoGITHUB_PAT. -
AGENTS.md:62-66—weight_prior_var == 0does not produce a usable least-squares fallback. Althoughget_map_estimates()selectscalc_ofv_ls, it subsequently evaluatesomega$est / weight_prior_varandsolve(omega$est / weight_prior_var)while building the optimizer data, so zero causes non-finite values/an error before fitting. Tell agents to usetype = "ls"; do not document zero prior weight as supported unless the implementation is fixed. -
AGENTS.md:129-131—parse_omega_matrix()does not accept CV% as an input format. It accepts a full covariance matrix or a lower-triangle vector of variances/covariances.create_block_from_cv()can create a diagonal lower-triangle block from a CV fraction, but that is a separate conversion. Correct the listed accepted formats. -
AGENTS.md:138-145— The return and error behavior is stated too broadly. Residual/g.o.f. fields are added only whenresiduals = TRUE(andmahalanobisends upNULLwhen they are skipped). Also, only the non-mixturemle_wrapper()call is inside thetryCatchthat returns an error object; mixture fits and errors elsewhere propagate normally. Qualify both statements so callers do not rely on fields or error handling that are not guaranteed.
Reviewed by Codex
- Fix `devtools::check()` invocation: flags belong in `args =`, not the positional `pkg` argument. - PKPDsim is a public repo, so no token is required to install it; note `GITHUB_PAT` only as an optional rate-limit workaround. - Do not document `weight_prior = 0` as a least-squares fallback; it makes `omega$est / weight_prior_var` non-finite. Point to `type = "ls"`. - Correct the omega input formats accepted by `parse_omega_matrix()` (full matrix or lower-triangle vector; CV% is `create_block_from_cv()`). - Qualify the return object: residual/g.o.f. fields require `residuals = TRUE`, and only the non-mixture fit returns an error object. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Addressed the Codex review — all five findings verified against source and fixed in e5e36e8.
No findings were rejected. 🤖 Generated with Claude Code |
roninsightrx
left a comment
There was a problem hiding this comment.
The five original findings are resolved, but remaining factual inaccuracies still prevent approval.
-
AGENTS.md:94-99— The Hessian-skipping description is only true for the non-mixture branch.R/get_map_estimates.R:243-249passes the user-suppliedskip_hessiandirectly for every mixture fit; only the non-mixture branch createsskip_hessian_mle <- skip_hessian || residualsat lines 297-309. Also, thenumDerivHessian path does not affect CWRES: CWRES comes fromcalc_cwres(), whileobj$fit$vcovis only a variance-covariance source/fallback. Qualify this paragraph as non-mixture behavior and remove the claim that both paths affect CWRES. -
AGENTS.md:47-61— Neithercheck_inputs()norparse_weight_prior()validates or collectively recognizes exactly the three listed values.check_inputs()only special-casesmap/pls,parse_weight_prior()only special-casespls, and an arbitrary string is not rejected and falls through with MAP-like behavior. Reword this as implementation special cases inget_map_estimates()/parse_weight_prior(), and explicitly note thattypeis currently not validated if agents need to rely on that behavior. -
AGENTS.md:83,114—ll_func_PKPDsim()computes the optimization objective, not a log-likelihood.calc_ofv_map()returns contributions on the-2 * log(likelihood)scale andll_func_PKPDsim()sums them. Change both descriptions to “objective function (OFV / -2 log-likelihood)” so agents do not get the sign and scale wrong when modifying likelihood or Hessian code. -
AGENTS.md:123—check_inputs()is described as comprehensive, but its own source calls it basic and it checks only required inputs for map/pls, censoring type, model class, and parameter names; omega/data/error/weights validation is distributed among later parsers. Change this role to “basic early validation” rather than suggesting all validation is centralized there.
Reviewed by Codex
jasmineirx
left a comment
There was a problem hiding this comment.
lgtm except one point of accuracy. plus codex had some outstanding comments i think.
| PKPDmap is an R package implementing Maximum A Posteriori (MAP) Bayesian | ||
| estimation for pharmacokinetic/pharmacodynamic (PK/PD) data. It depends heavily | ||
| on [PKPDsim](https://github.com/InsightRX/PKPDsim) (also an InsightRX package) | ||
| for ODE-based PK/PD simulation. PKPDsim is not on CRAN and is pulled from |
There was a problem hiding this comment.
PKPDsim is on CRAN: https://cran.r-project.org/web/packages/PKPDsim/index.html
Should we correct this to avoid confusion?
There was a problem hiding this comment.
Good catch — fixed in 40c1ead: the sentence now says PKPDsim is on CRAN, and notes that DESCRIPTION still carries a Remotes: InsightRX/PKPDsim entry so installs pull the GitHub development version.
- PKPDsim is on CRAN; correct the claim that it is not. Note that `DESCRIPTION` still carries a `Remotes:` entry, so installs pull the GitHub development version. - Qualify the Hessian-skip note as non-mixture-only (mixture fits pass `skip_hessian` through unchanged) and drop the incorrect claim that it affects CWRES; CWRES comes from `calc_cwres()`. - State that `type` is not validated: `map`/`pls`/`ls` are implementation special cases and any other string falls through to MAP-like behavior. - Describe `ll_func_PKPDsim()` as the objective function (OFV, i.e. `-2 * log(likelihood)`) rather than a log-likelihood. - `check_inputs()` is basic early validation, not comprehensive; the remaining validation is distributed among the `parse_*()` functions. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Addressed both rounds of feedback in 40c1ead. All findings verified against source; none were rejected. @jasmineirx — PKPDsim CRAN status. Correct. PKPDsim is on CRAN (1.4.1). Codex follow-up:
🤖 Generated with Claude Code |
Renames
CLAUDE.mdtoAGENTS.mdand updates its contents.Why AGENTS.md
AGENTS.mdis the cross-harness convention for agent instructions, so the same file is picked up by other AI coding agent tooling rather than only by Claude Code. The wording is now harness-agnostic ("agents" / "AI coding agents") instead of referring to one specific assistant.What the file contains
Remotes:).devtools::load_all(),devtools::test(), single-file test filtering,devtools::document(),devtools::check("--no-manual --as-cran").get_map_estimates()through theparse_*functions,mle_wrapper(),calc_residuals()andget_varcov_matrix(); a key-function table; parameter conventions (ETA, omega, IOV, fixed).Corrections to the previous content
While verifying the existing text against the source, a few things turned out to be inaccurate:
get_map_estimates()"supports five estimation methods via themethodargument". In factmethodis theoptim()method (default"BFGS"); the estimation approach is chosen bytype, whichcheck_inputs()/parse_weight_prior()accept as"map","pls"or"ls". The two are now documented separately.np,np_hybrid,get_np_estimates()) that do not exist onmaster.weight_prior— the actual control over prior strength, given on the SD scale and squared intoweight_prior_var— was undocumented.README.mdstill advertisesmap_flat_priorwhile the code acceptspls.Newly documented behavior that requires reading several files to discover:
cppattribute silently fall back toll_func_generic().residuals = TRUEthenumDeriv::hessian()call is skipped and the FOCE Jacobian vcov is preferred overfit$vcov— so that path drives both vcov and CWRES.map_estimatesobject, and the fact that optimizer failures return the error object instead of throwing.tests/testthat/nm/NONMEM fixtures use hard-coded reference values because NONMEM is licensed and not run in CI.Verification
Claims about commands and layout were checked against the repo:
devtools::load_all()succeeds, the argument defaults (type = "map",method = "BFGS") match, and bothdevtools::test()anddevtools::test(filter = "get_map_estimates")run with no failures (pre-existing warnings only). NoCLAUDE.mdremains in the repo.🤖 Generated with Claude Code