diff options
| author | Omni Worker <bot@omni.agent> | 2025-11-22 05:25:57 -0500 |
|---|---|---|
| committer | Omni Worker <bot@omni.agent> | 2025-11-22 05:25:57 -0500 |
| commit | e97d41858c67ca7b019493be2b436e32b8069118 (patch) | |
| tree | 4f021c4faa0f60428bfa3ad563c28ab64a491cec | |
| parent | cf32eb4ea6e2f8594fea7895fee38c9c2a838042 (diff) | |
fix: read amp log from start and use totalCredits for accuracy
Amp-Thread-ID:
https://ampcode.com/threads/T-5a2ca80d-5cba-409f-a262-6b5c652c257d
Co-authored-by: Amp <amp@ampcode.com>
| -rw-r--r-- | .tasks/tasks.jsonl | 3 | ||||
| -rw-r--r-- | Omni/Agent/Worker.hs | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/.tasks/tasks.jsonl b/.tasks/tasks.jsonl index 413d2b5..c0380e4 100644 --- a/.tasks/tasks.jsonl +++ b/.tasks/tasks.jsonl @@ -164,7 +164,7 @@ {"taskCreatedAt":"2025-11-21T22:31:20.872934097Z","taskDependencies":[],"taskDescription":null,"taskId":"t-rWblzNdp4.3","taskNamespace":null,"taskParent":"t-rWblzNdp4","taskPriority":"P2","taskStatus":"Done","taskTitle":"Implement smart base branch selection in Worker","taskType":"WorkTask","taskUpdatedAt":"2025-11-21T22:36:36.614180518Z"} {"taskCreatedAt":"2025-11-21T23:01:48.224051611Z","taskDependencies":[],"taskDescription":null,"taskId":"t-rWbnAjCJH","taskNamespace":null,"taskParent":null,"taskPriority":"P2","taskStatus":"Done","taskTitle":"Update start-worker.sh to use Haskell agent","taskType":"WorkTask","taskUpdatedAt":"2025-11-22T01:34:02.545292575Z"} {"taskCreatedAt":"2025-11-22T01:34:07.407341455Z","taskDependencies":[],"taskDescription":"Omni/Bild.hs:776 has a TODO: wrapper should just be removed, instead rely on upstream nixpkgs builders to make wrappers. This simplifies the codebase by removing manual bash script generation.","taskId":"t-rWbMpcV4v","taskNamespace":"Omni/Bild.hs","taskParent":null,"taskPriority":"P2","taskStatus":"Done","taskTitle":"Remove manual wrapper generation in Omni/Bild","taskType":"WorkTask","taskUpdatedAt":"2025-11-22T03:21:49.357422745Z"} -{"taskCreatedAt":"2025-11-22T01:34:12.233596517Z","taskDependencies":[],"taskDescription":"Implement a metrics view in the Admin dashboard (Biz/PodcastItLater/Admin.py). Show total users, active subscriptions, and recent submission counts. Ref: Biz/PodcastItLater/DESIGN.md","taskId":"t-rWbMpxaBk","taskNamespace":"Biz/PodcastItLater.hs","taskParent":null,"taskPriority":"P2","taskStatus":"InProgress","taskTitle":"Implement metrics view in Admin dashboard","taskType":"WorkTask","taskUpdatedAt":"2025-11-22T10:08:07.856723065Z"} +{"taskCreatedAt":"2025-11-22T01:34:12.233596517Z","taskDependencies":[],"taskDescription":"Implement a metrics view in the Admin dashboard (Biz/PodcastItLater/Admin.py). Show total users, active subscriptions, and recent submission counts. Ref: Biz/PodcastItLater/DESIGN.md","taskId":"t-rWbMpxaBk","taskNamespace":"Biz/PodcastItLater.hs","taskParent":null,"taskPriority":"P2","taskStatus":"InProgress","taskTitle":"Implement metrics view in Admin dashboard","taskType":"WorkTask","taskUpdatedAt":"2025-11-22T10:17:01.259540226Z"} {"taskCreatedAt":"2025-11-22T01:34:19.451799517Z","taskDependencies":[],"taskDescription":"Update Omni/Agent/start-worker.sh to invoke the new Haskell-based agent binary ('agent start <name>') instead of running the legacy bash loop. Ensure it still sets up the environment correctly. The agent binary handles the loop internally.","taskId":"t-rWbMq1snX","taskNamespace":"Omni/Agent.hs","taskParent":null,"taskPriority":"P2","taskStatus":"Done","taskTitle":"Update start-worker.sh to use Haskell agent","taskType":"WorkTask","taskUpdatedAt":"2025-11-22T01:57:09.161716208Z"} {"taskCreatedAt":"2025-11-22T02:13:44.805917094Z","taskDependencies":[],"taskDescription":"Modify Omni/Agent/Git.hs to proactively clean up stale rebase/merge states before attempting operations. The worker should attempt 'git rebase --abort' (ignoring errors) before syncing to prevent 'already rebase-merge' errors.","taskId":"t-rWbP06f2O","taskNamespace":null,"taskParent":null,"taskPriority":"P2","taskStatus":"Done","taskTitle":"Make worker agent robust to stale git states","taskType":"WorkTask","taskUpdatedAt":"2025-11-22T02:14:40.413090556Z"} {"taskCreatedAt":"2025-11-22T02:26:44.02456019Z","taskDependencies":[],"taskDescription":"Modify Omni/Agent/Git.hs to check for .git/rebase-merge or .git/rebase-apply before running git rebase --abort. This avoids blindly running abort commands.","taskId":"t-rWbPQPLps","taskNamespace":null,"taskParent":null,"taskPriority":"P2","taskStatus":"Done","taskTitle":"Detect in-progress rebase before aborting in Agent","taskType":"WorkTask","taskUpdatedAt":"2025-11-22T02:27:45.377866012Z"} @@ -175,3 +175,4 @@ {"taskCreatedAt":"2025-11-22T09:50:59.154884329Z","taskDependencies":[],"taskDescription":"1. Add Thread ID to the status bar (requires log parsing later, but add field now). 2. Make the status layout responsive or vertical (4 lines) to fit on small screens (iPhone). 3. Reserve more lines in init.","taskId":"t-rWciWJYsi","taskNamespace":"Omni/Agent/Log.hs","taskParent":null,"taskPriority":"P2","taskStatus":"Done","taskTitle":"Improve Agent Status UI for mobile & debugging","taskType":"WorkTask","taskUpdatedAt":"2025-11-22T09:52:36.176467065Z"} {"taskCreatedAt":"2025-11-22T10:09:23.249166289Z","taskDependencies":[],"taskDescription":null,"taskId":"t-rWck9sDOA","taskNamespace":"Omni/Agent.hs","taskParent":null,"taskPriority":"P2","taskStatus":"Done","taskTitle":"Split Thread and Credits in Worker status bar","taskType":"WorkTask","taskUpdatedAt":"2025-11-22T10:10:17.800528662Z"} {"taskCreatedAt":"2025-11-22T10:12:35.129294132Z","taskDependencies":[{"depId":"t-rWck9sDOA","depType":"DiscoveredFrom"}],"taskDescription":null,"taskId":"t-rWckmrKBm","taskNamespace":null,"taskParent":null,"taskPriority":"P2","taskStatus":"Done","taskTitle":"Fix Worker status bar activity not updating","taskType":"WorkTask","taskUpdatedAt":"2025-11-22T10:14:43.612634394Z"} +{"taskCreatedAt":"2025-11-22T10:24:04.441689132Z","taskDependencies":[{"depId":"t-rWckmrKBm","depType":"DiscoveredFrom"}],"taskDescription":null,"taskId":"t-rWcl762fd","taskNamespace":null,"taskParent":null,"taskPriority":"P2","taskStatus":"Done","taskTitle":"Fix credit calculation in Worker status bar","taskType":"WorkTask","taskUpdatedAt":"2025-11-22T10:25:51.468062833Z"} diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs index 4ff9042..7afc849 100644 --- a/Omni/Agent/Worker.hs +++ b/Omni/Agent/Worker.hs @@ -227,8 +227,7 @@ monitorLog :: FilePath -> IO () monitorLog logPath = do waitForFile logPath IO.withFile logPath IO.ReadMode <| \h -> do - -- Tail the file - IO.hSeek h IO.SeekFromEnd 0 + -- Start from beginning of file (don't seek to end) forever <| do eof <- IO.hIsEOF h if eof @@ -263,11 +262,12 @@ parseAndUpdate line = do _ -> pure () -- Extract cost from usage-ledger:event - -- Pattern: {"addedCredits": 0.123, "message": "usage-ledger:event", ...} - case KM.lookup "addedCredits" obj of + -- Pattern: {"totalCredits": 1.54, "message": "usage-ledger:event", ...} + -- We use totalCredits to be robust against missed lines and restarts. + case KM.lookup "totalCredits" obj of Just (Aeson.Number n) -> - let cost = Scientific.toRealFloat n - in AgentLog.update (\s -> s {AgentLog.statusCredits = AgentLog.statusCredits s + cost}) + let total = Scientific.toRealFloat n + in AgentLog.update (\s -> s {AgentLog.statusCredits = total}) _ -> pure () timeTicker :: IO () |
