Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ NOTE: all releases may include dependency updates, not specifically mentioned
## UNRELEASED

- feat: integrate try-as library [#912](https://github.com/hypermodeinc/modus/pull/912)
- feat: improve sentry usage [#931](https://github.com/hypermodeinc/modus/pull/931)
- feat: improve sentry usage [#931](https://github.com/hypermodeinc/modus/pull/931) [#937](https://github.com/hypermodeinc/modus/pull/937)
- fix: write inference history directly [#938](https://github.com/hypermodeinc/modus/pull/938)

## 2025-07-03 - Runtime v0.18.3

Expand Down
6 changes: 3 additions & 3 deletions runtime/db/agentstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func writeAgentStateToModusDB(ctx context.Context, state AgentState) error {
span, ctx := sentryutils.NewSpanForCurrentFunc(ctx)
defer span.Finish()

gid, _, _, err := modusgraph.Upsert(ctx, GlobalModusDbEngine, state)
gid, _, _, err := modusgraph.Upsert(ctx, globalModusDbEngine, state)
state.Gid = gid

return err
Expand All @@ -93,7 +93,7 @@ func getAgentStateFromModusDB(ctx context.Context, id string) (*AgentState, erro
span, ctx := sentryutils.NewSpanForCurrentFunc(ctx)
defer span.Finish()

_, result, err := modusgraph.Get[AgentState](ctx, GlobalModusDbEngine, modusgraph.ConstrainedField{
_, result, err := modusgraph.Get[AgentState](ctx, globalModusDbEngine, modusgraph.ConstrainedField{
Key: "id",
Value: id,
})
Expand All @@ -108,7 +108,7 @@ func queryActiveAgentsFromModusDB(ctx context.Context) ([]AgentState, error) {
span, ctx := sentryutils.NewSpanForCurrentFunc(ctx)
defer span.Finish()

_, results, err := modusgraph.Query[AgentState](ctx, GlobalModusDbEngine, modusgraph.QueryParams{
_, results, err := modusgraph.Query[AgentState](ctx, globalModusDbEngine, modusgraph.QueryParams{
Filter: &modusgraph.Filter{
Not: &modusgraph.Filter{
Field: "status",
Expand Down
17 changes: 3 additions & 14 deletions runtime/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"os"
"strconv"
"sync"
"time"

"github.com/hypermodeinc/modus/runtime/app"
"github.com/hypermodeinc/modus/runtime/logger"
Expand All @@ -28,24 +27,16 @@ import (

var errDbNotConfigured = errors.New("database not configured")

const inferenceRefresherInterval = 5 * time.Second

type runtimePostgresWriter struct {
dbpool *pgxpool.Pool
buffer chan inferenceHistory
quit chan struct{}
done chan struct{}
once sync.Once
}

func Stop(ctx context.Context) {
pool, _ := globalRuntimePostgresWriter.GetPool(ctx)
pool, _ := globalRuntimePostgresWriter.getPool(ctx)
if pool == nil {
return
}

close(globalRuntimePostgresWriter.quit)
<-globalRuntimePostgresWriter.done
pool.Close()
}

Expand All @@ -67,16 +58,14 @@ func Initialize(ctx context.Context) {
return
}

// this will initialize the pool and start the worker
_, err := globalRuntimePostgresWriter.GetPool(ctx)
_, err := globalRuntimePostgresWriter.getPool(ctx)
if err != nil {
logger.Warn(ctx, err).Msg("Metadata database is not available.")
}
go globalRuntimePostgresWriter.worker(ctx)
}

func GetTx(ctx context.Context) (pgx.Tx, error) {
pool, err := globalRuntimePostgresWriter.GetPool(ctx)
pool, err := globalRuntimePostgresWriter.getPool(ctx)
if err != nil {
return nil, err
}
Expand Down
Loading
Loading