WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s

This commit is contained in:
yawan
2026-09-22 16:19:06 +08:00
commit f7fc992f57
3929 changed files with 1006607 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
package workbench
import (
"context"
"errors"
"strings"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
)
type instructionStub struct {
text string
err error
}
type disabledInstructionAgentStub struct{ interfaces.CustomAgentService }
func (disabledInstructionAgentStub) GetAgentByID(ctx context.Context, id string) (*types.CustomAgent, error) {
tenant, _ := types.TenantIDFromContext(ctx)
return &types.CustomAgent{ID: id, TenantID: tenant, Visibility: "global", Enabled: false, Config: types.CustomAgentConfig{ModelID: "model"}}, nil
}
func TestDisabledAgentCannotGenerateWithoutInstructionResolver(t *testing.T) {
s, ctx, _, model := generationHarness(t)
s.agents = disabledInstructionAgentStub{}
if _, err := s.complete(ctx, "disabled", "system", "prompt"); !errors.Is(err, ErrInvalid) {
t.Fatalf("expected disabled Agent rejection, got %v", err)
}
if len(model.messages) != 0 {
t.Fatal("disabled Agent reached provider")
}
}
func (s instructionStub) ResolveAgentInstructions(context.Context, *types.CustomAgent) (string, error) {
return s.text, s.err
}
func TestMountedInstructionsParticipateInGenerationAndBudget(t *testing.T) {
s, ctx, _, model := generationHarness(t)
s.SetInstructionResolver(instructionStub{text: "技能规则:先列判断依据,再给案例。"})
if _, err := s.complete(ctx, "agent", "system", "prompt"); err != nil {
t.Fatal(err)
}
if !strings.Contains(model.messages[0].Content, "技能规则:先列判断依据") {
t.Fatal("mounted instruction missing from provider request")
}
s.models = generationModelStub{model: model, parameters: types.ModelParameters{ContextWindow: 4096, MaxOutputTokens: 512}}
s.SetInstructionResolver(instructionStub{text: strings.Repeat("很长的技能规则", 3000)})
model.messages = nil
if _, err := s.complete(ctx, "agent", "system", "prompt"); !errors.Is(err, ErrInvalid) {
t.Fatalf("expected budget rejection, got %v", err)
}
if len(model.messages) != 0 {
t.Fatal("oversized skills reached model")
}
}
func TestUnavailableInstructionStopsGeneration(t *testing.T) {
s, ctx, _, model := generationHarness(t)
s.SetInstructionResolver(instructionStub{err: ErrForbidden})
if _, err := s.complete(ctx, "agent", "system", "prompt"); !errors.Is(err, ErrForbidden) {
t.Fatalf("got %v", err)
}
if len(model.messages) != 0 {
t.Fatal("generation silently ignored unavailable instruction")
}
}