Repository navigation
fix(agent-lightning): report the applied penalty in multiplicative PolicyReward mode - #4418
Conversation
…licyReward mode With RewardConfig(multiplicative=True) a violation scales the base reward by multiplicative_factor, but get_stats() and the emitted policy_penalty still used the additive severity table, so a critical violation that halved a reward of 1.0 was recorded as -100. The penalty is now the amount the scaling took off the base reward. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Shivam Sharma <192242476+ShivamSharma43@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Shivam Sharma <192242476+ShivamSharma43@users.noreply.github.com>
PR Review Summary
Verdict: AI review comments are untrusted advisory output. The summary reports workflow-generated completion status only, not model-authored pass/fail claims. |
|
🟡 Contributor Check: MEDIUM
Automated check by AGT Contributor Check. |
MohammadHaroonAbuomar
left a comment
There was a problem hiding this comment.
- docs/specs/AGENT-LIGHTNING-FAST-PATH-1.0.md:423 The fix is verified: in multiplicative mode the recorded and emitted penalty is now the applied scaling (two of the three new tests fail on main and pass here; 205 passed). One item: the normative spec still describes the old behaviour. Section 6.5 steps 3 to 5 say the total penalty comes from the severity mapping before the mode branch, and line 447 describes
policy_penaltyas the total penalty value. Please reword them so the penalty is the severity-table sum in additive mode andbase_reward * multiplicative_factor - base_rewardin multiplicative mode, taken before the clean bonus and the clamp, and saypolicy_penaltyis the penalty applied in the active mode. The sibling #4419 updated the spec for its change, so this keeps the two in step. Approve follows.
…putation spec Signed-off-by: Shivam Sharma <192242476+ShivamSharma43@users.noreply.github.com>
…icative-penalty-stats Signed-off-by: Shivam Sharma <192242476+ShivamSharma43@users.noreply.github.com> # Conflicts: # CHANGELOG.md
|
Reworded the spec in 019cdb7. Section 6.5 steps 3–5 now say the penalty is |
Verified: in multiplicative mode the recorded and emitted penalty is the applied scaling; two of the three new tests fail on main and pass here; the spec section 6.5 and the policy_penalty description now match the code; 205 passed.
MohammadHaroonAbuomar
left a comment
There was a problem hiding this comment.
Verified: in multiplicative mode the recorded and emitted penalty is the applied scaling; two of the three new tests fail on main and pass here; the spec section 6.5 and the policy_penalty description now match the code; 205 passed. CI is green on this head.
…oft#4426, advance watermarks - 6dc2093 (microsoft#4418): code and tests already in the fork; sync the reward computation spec so it matches the applied-penalty behaviour - 46b370e (microsoft#4259 --sync-registry): not adopted; generate_workflows.py --check is already red in the fork (hand-added repository gates) and the new symlink tests raise WinError 1314 on unprivileged Windows - PR microsoft#4427 (Parmana verifier integration): not adopted; head bc596b0 scanned for hidden content, clean - issue microsoft#4426 (ApprovalResolution signature RFC): WATCH - baseline: commit 46b370e, PR 4427, issue 4426 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Related Issue
None. This is a bug I found in
agent_lightning_gov.reward.PolicyReward; the sections below are filled in as the template asks.Problem & Solution
Problem.
PolicyReward.__call__always computed the additive severity penalty, then picked the reward formula:In multiplicative mode the severity penalty is not used for the reward, but it is still what goes into
get_stats()(total_penalties,avg_penalty) and into thepolicy_penaltyvalue emitted to Agent-Lightning next tofinalandbase:So the emitted record says
final=0.5, base=1.0, policy_penalty=-100, which do not add up, and a dashboard of the penalty shows the additive table rather than what training saw.Solution. In multiplicative mode the penalty is now the amount the scaling took off the base reward (
base * factor - base), taken before the clean bonus and the min/max bounds, as the additive penalty already is. Additive mode, and the reward itself in both modes, are unchanged.Impact on Your Work
Anyone training with
multiplicative=Trueand readingget_stats()or the emittedpolicy_penaltygets numbers that do not describe the rewards that were used.Timeline
None.
Alternatives Considered
final - base. That would fold the clean bonus and the min/max clamp into the penalty, unlike additive mode, wherepolicy_penaltyis the severity sum before them.Type of Change
Package(s) Affected
Testing
Unit Testing
In
agent-lightning/tests/test_lightning_comprehensive.py,TestPolicyRewardMultiplicativegainstest_multiplicative_stats_record_applied_penalty(a critical violation at factor 0.5 recordstotal_penalties == -0.5) andtest_multiplicative_emits_applied_penalty(base 8.0 at factor 0.25 emitspolicy_penalty == -6.0); both fail on main.test_additive_stats_record_severity_penaltypins that additive mode still records the severity penalty.Manual Testing
agent-lightning/tests: 206 passed.ruff check --select E,F,W --ignore E501(as in CI): clean on the changed source file; the test file's only findings are the four existingE731lambdas inTestCompositeReward, unchanged on main.cspellwith.cspell.jsonon the changed files; no issues on added lines.Checklist
Attribution & Prior Art
None.
AI Assistance
I used Claude Code (Claude Opus) to help find the bug and draft the fix and tests. I reviewed the full diff and will handle review comments myself.
IP, Patents, and Licensing
🤖 Generated with Claude Code